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.
我在我的页面上有多个嵌套视图ui-view,其中有相应的状态可以在这些视图中设置模板。当我转换到子状态时,将调用与其每个父状态关联的控制器。我想阻止这个。例如,如果我转换到状态root.question.mcq.menu,则调用与状态root.question.mcq关联的控制器。
How can I prevent this so that only the controller associated with root.question.mcq.menu
gets called.
如何防止这种情况,以便只调用与root.question.mcq.menu关联的控制器。
1 个解决方案
#1
1
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.
这取决于你来自哪里。您是来自父级还是来自目标状态的兄弟,不应该初始化父控制器。但是如果你来自任何其他状态,父控制器将被初始化。如果这种行为对您不利,那么您可能遇到了设计问题。
#1
1
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.
这取决于你来自哪里。您是来自父级还是来自目标状态的兄弟,不应该初始化父控制器。但是如果你来自任何其他状态,父控制器将被初始化。如果这种行为对您不利,那么您可能遇到了设计问题。