I have a complex ui.state set up that for url ease I take users to a 'base' subpage url and then provide tabs to filter content on the page. For example:
/page/unique-page-slug <- 'base' subpage url
/page/unique-page-slug/popular <- filtered content subpage url
the issue im encountering is that despite having a controller on each state i cant seem to trigger when the states change after the first time.
var myapp = angular.module('myapp', ["ui.router"])
myapp.config(function($stateProvider, $urlRouterProvider){
// For any unmatched url, send to /route1
$urlRouterProvider.otherwise("/route1")
$stateProvider
.state('route1', {
url: "/route1",
templateUrl: "route1.html",
controller: function($scope){
console.log('parent triggered');
}
})
.state('route1.list', {
url: "/list",
templateUrl: "route1.list.html",
controller: function($scope){
$scope.items = ["A", "List", "Of", "Items"];
console.log('child triggered');
}
})
})
Heres is a plunkr example. Note, that when i go to route 1 it logs 'parent triggered', then go to a sub state i get 'child triggered', when i go back to the parent i dont get anything triggered, but upon re-entering the sub state it retriggers 'child state'
What i am trying to do is have it trigger 'parent triggered' when i go back to the parent state.