每次访问View时都要重新初始化Controller-Ionic Framework [英] Reinitialize Controller every time when visiting View - Ionic Framework
本文介绍了每次访问View时都要重新初始化Controller-Ionic Framework的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序中有两个视图,每个视图分配了两个控制器. 在这里,每次导航到特定视图时,我都需要重新初始化控制器.
Hi i'm having two views in my app with two controllers assigned to each. Here i need to reinitialize the controller every time when ever i navigate to particular view.
Angular脚本:
Angular Script:
.state('app.pnrlist', {
url: "/pnrlist",
views: {
'menuContent': {
templateUrl: "templates/test.html",
controller: "testControl",
reload: true
}
},
reload:true
})
.state('app.home', {
url: "/home",
views: {
'menuContent': {
templateUrl: "templates/home.html",
controller:"homeControl",
reload:true
}
},
reload:true
})
HTML内容
<ion-content>
<ion-list>
<ion-item nav-clear menu-close href="#/app/home">
Home
</ion-item>
<ion-item nav-clear menu-close href="#/app/pnrlist">
PNR List
</ion-item>
</ion-list>
</ion-content>
我试图在堆栈上实现许多解决方案,但是没有一个帮助我. 解决方案已尝试1 / 解决方案尝试2
I have tried to implement many solutions on stack but none helped me. Solution Tried 1 / Solution Tried 2
推荐答案
如果视图未更新,则禁用缓存可能会有所帮助
If its a matter of the View not updating, disabling the Cache may help
即
.state('app.home', {
url: "/home",
cache: false,
默认情况下,视图会被缓存以提高性能.您还可以通过"cache-view"属性禁用缓存
As by default, views are cached to improve performance. You can also disable the cache via the 'cache-view' attribute
<ion-view cache-view="false" view-title="My Title!">
...
</ion-view>
这篇关于每次访问View时都要重新初始化Controller-Ionic Framework的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文