如何在每次访问状态时执行控制器块? [英] How to make so a controller block is executed everytime a state is accessed?
本文介绍了如何在每次访问状态时执行控制器块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个连接到状态的控制器,每次访问该状态时,我都需要我的控制器运行一个块来进行验证.
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.
我该怎么做?
推荐答案
对于重新加载控制器每次你应该提到 reload: true
选项在你的 .state
声明中-路由器
For reloading controller every time you should mention reload: true
option on you .state
declaration of ui-router
示例代码
$stateProvider
.state('state1', {
templateUrl: 'state1.html',
controller: `state1Ctrl`,
reload: true //forcefully reload route and load controller again
})
你也可以参考这个SO问题
Also you could refer this SO Question
这篇关于如何在每次访问状态时执行控制器块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文