Angularjs Route does not seem to be working -
I have 4 files index.html, test.html, module.js, and name.json
For some reason it starts working for me on my localhost. Either my code is wrong or my routes are wrong, I just want to display my test.html page.
index.html
& lt; ! DOCTYPE html & gt; & Lt; Html data-ng-app = "mysite" & gt; & Lt; Top & gt; & Lt; Title & gt; Practice with kangaroo & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div & gt; & Lt; Div data-ng-view = "" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Script type = "text / javascript" src = "http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js"></script> & Lt; Script type = "text / javascript" src = "module.js" & gt; & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;
test.html
& lt; / tr & gt; & lt; / table & gt; & lt; p & Gt; Welcome {{Search}}
module.js
< Pre> var app = angular module ("mysite", []); App.config (function ($ migration provider) {$ routeProvider. When ("/", {controller: "name-controller", templateUrl: "Test.html"}). Otherwise ({redirectTo: "/"})}}; App.controller ("name-controller", function ($ radius, $ http) {$ http.get ("name.json "). Success (data) {$ scope.names = data;}}}}
name.json
{"Name": "Nelson"}, {"name": "Shirley" {"name": "jenny"}, {"name" {"Name": "yen"}, {"name": "mother"}, {"name": "father"}, {"name": "korean"}]
please see here
a) Please refer to angular-route.js Add b) In your angle module var app = angular.module ('mysite', ['ngRoute']) inject ngRoute;
& lt ;! DOCTYPE html & gt; & Lt; Html data-ng-app = "mysite" & gt; & Lt; Top & gt; & Lt; Script src = "// cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.js"></script> & Lt; Script src = "// cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular-route.js"></script> & Lt; Link rel = "stylesheet" href = "style.css" /> & Lt; Script src = "script.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div ng-view = "" & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;
JS:
var app = angular Module ('mysite', ['ngRoute']); {{RedirectTo: "/"});} ("{" " ); App.controller ("name-controller", function ($ radius, $ http) {$ http.get ("name.json"). Success (function (data) {$ scope.names = data;})}};
Comments
Post a Comment