Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UI-Router AngularJs: Prevent calling parent state controller when transitioning to child state

I have multiple nested views ui-view on my page with corresponding states to set templates in those views. When I transition to a child state, controller associated to each of its parent states gets called. I want to prevent this. For example, if I transition to state root.question.mcq.menu, the controller associated with state root.question.mcq too gets called.

How can I prevent this so that only the controller associated with root.question.mcq.menu gets called.

like image 279
suheb Avatar asked Jul 03 '15 12:07

suheb


1 Answers

It depends where you come from. Do you come from the parent or from a sibling of the target state the parent controller should not be initialized. But if you come from any other state the parent controller will be initialized. If this behavior is wrong for you then you probably have a design issue.

like image 184
Michael Avatar answered Oct 18 '22 11:10

Michael