I am trying to call a controller which should be linked with the home.category route but it isn\'t being called. What\'s wrong in it?
$statePro
Another reason the controller may not be called is if you have multiple views for a state and don't put the controller inside the views object. This is difficult to find because there is no error. It just doesn't get called.
This controller won't be called:
.state('home', {
url: '/',
controller: function($scope){ $scope.someThings = "some stuff"; },
views: {
"view1": {
template: '{{someThings}}
'
},
"": {
template:
'Some other stuff
'
}
}
})
The controller must go inside the views object:
.state('home', {
url: '/',
views: {
"view1": {
template: '{{someThings}}
',
controller: function($scope){ $scope.someThings = "some stuff"; },
},
"": {
template:
'Some other stuff
'
}
}
})