Encountered an issue while trying to reach HomeController (module controller). Upon clicking the "home" link, an error appeared in the console stating that "HomeController is not a function; undefined.
Could you advise on where I should register this controller? Thanks, 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";
}])
})();
module Controller (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]