Friday, 15 March 2013

AngularJS: Triggering a controller to always change a substate if needed -



AngularJS: Triggering a controller to always change a substate if needed -

i using in angular app ui-router , have view has 2 sub states under controller. 1 time navigating "homestate", controller checks case , if occurs, navigates "homestate.substate1", else "homestate.substate2". simplify issue :

myapp.controller('myctrl', ['$scope', function($scope) { if(certaincase) { state.go('homestate.substate1'); } else { state.go('homestate.substate2'); } }]);

while considering above code, familar angular means when navigating "/homestate" controller triggered , redirect right substate correctly.

the problem occurs in general flow:

we navigate "homestate" (which redirected correctly substate) now navigate "otherstate" then, "homestate" - at point problem occurs! controller no longer triggers if case , state freezes @ "homestate" instead of redirecting substate1/substate2 (which affects ui!).

what im trying forcing controller check case again, though might wrong thinking, i'll glad if clarify that.

angularjs controller scope angular-ui-router

No comments:

Post a Comment