Statement: This is a discussion of the problem, not to solve the problem, I hope that the more familiar with the friends can see, maybe you can help me
Ng-view is a directive this complements the $route service by including the rendered template of the current route into th E main layout (index.html) file. Every time the current route changes, the included view changes with it according to the configuration of the $route servi Ce.
Above is the angular JS Official document in a section of the description of Ng-view, the general meaning is ng-view this instruction can be routed through the rendered template into the home page display, each time the route changes, the view will be based on the configuration of the route to display the corresponding template content.
The implementation can be written in the same or separate write:
1. Co-write
var ctrls=angular.module ("AAA", [
"Ngroute"
]);
Ctrls.config (function ($routeProvider) {
$routeProvider. When ("/hello", {
Templateurl: "Tpls/hello.html",
Controller: "Helloctrl"
}). When ("/xxx", {
Templateurl: "Tpls/yyy.html",
Controller: "ZZZ"
}). Otherwise ({
Redirectto: "/hello"
});
});
Ctrls.controller (' Helloctrl ', [' $scope ', function ($scope) {
$scope. hello= "Hello World";
}]);
After testing, the method is feasible.
2. Write separately
App.js:
var app=angular.module ("AAA", [
"Ngroute", "Ctrls"
]);
App. Config (function ($routeProvider) {
$routeProvider. When ("/hello", {
Templateurl: "Tpls/hello.html",
Controller: "Helloctrl"
}). When ("/xxx", {
Templateurl: "Tpls/yyy.html",
Controller: "ZZZ"
}). Otherwise ({
Redirectto: "/hello"
});
});
cntroller.js:
var ctrls=angular.module ("AAA", [
"Ngroute"
]);
Ctrls.controller (' Helloctrl ', [' $scope ', function ($scope) {
$scope. hello= "Hello World";
}]);
After testing this method did not get the corresponding effect, but also did not error.
If you know the reason, I hope you comment below, thank you very much
I will continue to study and will issue answers to this question later on.
Discussion on some problems of ng-view in angular JS