nie mógł dotrzeć do homeController (kontrolera modułu). podczas klikania na „domowym” link uzyskiwanie błąd na konsoli że „HomeController nie jest funkcją,. Nieokreślonejangular.js: 13708 Błąd: [ng: areq] Argument "homeController" nie jest funkcją, ale nieokreślony
Więc, gdzie muszę się zarejestrować ten kontroler Dzięki, Rahul
twoPageApp.js
* Created by rahul on 9/24/2016.
*/
(function(){
angular.module("twoPageApp",["ngRoute"])
.config(function($routeProvider){
$routeProvider
.when('/home',{
templateUrl:'/JS/twoPageAppJS/partials/home.html',
controller: 'homeController',
resolve:{
homeContent:['$http',function($http){
return $http.get('/homeContent.json');
}]
}
})
.when('/page_one',{
templateUrl:'/Js/twoPageAppJS/partials/pageOne.html',
controller:'pageOneController',
resolve:{
homeContent:['$http',function($http){
return $http.get('/pageOneContent.json');
}]
}
})
.when('/page_two',{
templateUrl:'/JS/twoPageAppJS/partials/pageTwo.html',
controller:'pageTwoController.js',
resolve:{
homeContent:['$http',function($http){
return $http.get('/pageTwoContent.json');
}]
}
})
});
})();
twoPageApp.Controller.js
(function(){
angular.module("twoPageApp").controller("tpaController",
['$scope',function($scope){
$scope.name="this is twoPageApp js controller";
}])
})();
moduł sterowania (homeController.js)
/**
* Created by rahul on 9/24/2016.
*/
(function(){
angular.module("twoPageApp",[]) //here is the change...
.controller("homeController",['$scope','$rootScope','homeContent',function($scope,$rootScope,homeContent){
$rootScope.stub={
homeContent:homeContent.data
};
$scope.hello="rahul";
console.log("raja");
}]);
})();
home.jsp
[![<div ng-app="twoPageApp" ng-controller="tpaController">
<div>
<a href="#/home">home</a>
<a href="#/page_one">page One</a>
<a href="#/page_two">page Two</a>
</div>
<div ng-view></div>
</div>][1]][1]
Jeśli utworzysz jsfiddle, które będą pomocne w zrozumieniu więcej problemów, Znalazłem kilka problemów wymienionych w mojej odpowiedzi. –