I have a controller attached to a state, and everytime said state is accessed, I need my controller to run a block where I do a verification.
How can I do this?
I have a controller attached to a state, and everytime said state is accessed, I need my controller to run a block where I do a verification.
How can I do this?
For reloading controller every time you should mention reload: true
option on you .state
declaration of ui-router
Sample Code
$stateProvider
.state('state1', {
templateUrl: 'state1.html',
controller: `state1Ctrl`,
reload: true //forcefully reload route and load controller again
})
Also you could refer this SO Question
In order to call a particular function every time your location changes, you can also define the function in html as:
<div ng-init="allDealerListing()">
So whenever the particular div in html is loaded the function is called automatically.
Hence upon change of state function is called
controller do execute each time you can call an function for example init() function like below
.controller('test',function($scope){
$scope.init = function( ){
// your code block here
}
$scope.init();
});