AngularJS,UI的SREF-OPTS无助重装应用程序 [英] AngularJS, ui-sref-opts does not help reloading the app
问题描述
我种在这里停留在这种情况下,我需要我的应用程序从一个工程,另一个变化时重新加载。我试过很多东西,我一直在寻找遍地找到一个解决方案。
我的应用程序是很复杂的,如果我尝试这种在一个孤立的情况下它完美的作品,因为它应该。
的http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.directive:ui-sref
< NG-斗篷&GT李纳克重复=,在app.projects工程;
<一个UI的SREF =app.channel({专案编号:project.id,渠道ID:project.channels [0] .ID})UI-SREF-OPTS ={重载:真的,通知:真正}级=主动>
<跨度> {{project.name}}< / SPAN>
&所述; / A>
< /李>
凡重要的部分是:
UI-SREF-OPTS ={重载:真的,通知:真正}
在我的路线文件,我有很多嵌套的路线和观点,我也有一个自定义authenicator成立。当我剥大部分下来,它的工作原理。这就是为什么我不可以对codePEN或类似的东西。任何code例如
现在我的问题是,是否有任何已知的问题与UI的路由器与认证,或者其他任何原因,为什么UI的SREF-OPTS不会重新加载该页面使用的时候吗?
对不起,那种不确定的问题,但也许有人能帮助我。
编辑:更多的信息和code
好吧,我会尽我所能为您提供相关的信息。
这是我的config.router.js是如何设置的。
angular.module(应用)
。跑(
// Authenicator在这里
)
的.config(
['$ stateProvider','$ urlRouterProvider','JQ_CONFIG','$ authProvider',
功能($ stateProvider,$ urlRouterProvider,JQ_CONFIG,$ authProvider){
// ... .STATE('app.channel',{
网址:'/项目/ {专案编号} / {}的channelID,
观点:{
'':{
templateUrl:TPL /渠道/ index.html的
}
},
解析:{
DEPS:['$ ocLazyLoad',
功能($ ocLazyLoad){
返回$ ocLazyLoad.load('angularFileUpload')。然后(
功能(){
返回$ ocLazyLoad.load([ ]);
}
);
}
]
}
}) // ...
}
]
);
这可能取决于指令缓存视图=FALSE
。通常情况下,你必须把它放在<离子视图>
指令在你要去的页面,你的情况在 TPL /渠道/的index.html
。但是,如果你嵌套了看法,你应该把它放在每个视图。
我有一个嵌套的标签视图同样的问题。我有一系列的标签,并在他们里面的一个,有两个选项卡选择其他视图。
<离子标签类=标签图标,顶部的标签颜色活性阳性> <! - 主页选项卡 - >
<离子分页标题=我的资讯图标客=离子IOS-家庭纲要图标上=离子IOS-家UI-SREF =main.wall>
<离子导航视图名称=选项卡上墙>< /离子NAV-视图>
< /离子标签> <! - 邮件选项卡 - >
<离子分页标题=信息图标关=离子IOS-电子邮件纲要图标上=离子IOS的电子邮件UI-SREF =main.message的选项卡UI-SREF-OPTS ={重载:真的,通知:真正}>
<离子导航视图名称=选项卡上的消息>< /离子NAV-视图>
< /离子标签>
< /离子标签>
为了使重装工作,我不得不把指令缓存视图=FALSE
无论是在容器
<离子视图缓存视图=false的>
<离子标签类=标签颜色活性阳性片条纹标签消息标签顶> <! - 消息选项卡 - >
<离子分页标题=消息UI-SREF =main.message线程UI-SREF-OPTS ={重载:真的,通知:真正}>
<离子导航视图名称=子选项卡的消息>< /离子NAV-视图>
< /离子标签> <! - 通知选项卡 - >
<离子分页标题=通知UI-SREF =main.notifications>
<离子导航视图名称=子选项卡的通知>< /离子NAV-视图>
< /离子标签>< /离子标签>
和页面
<离子查看查看标题=消息主题级=线程缓存视图=false的>
<离子内容类=有,有标签的选项卡顶>
...
I'm kind of stuck here in this situation, where I need my app to reload when changing from one "project" to another. I've tried many things and I have been searching over and over to find a solution.
My app is kind of complex, and if I try this in an isolated scenario it works perfectly, as it should. http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.directive:ui-sref
<li ng-repeat="project in app.projects" ng-cloak>
<a ui-sref="app.channel({projectId:project.id, channelId: project.channels[0].id})" ui-sref-opts="{reload: true, notify: true}" class="active">
<span>{{ project.name }}</span>
</a>
</li>
Where the important part would be:
ui-sref-opts="{reload: true, notify: true}
In my routes file I have many nested routes and views and I also have a custom authenicator set up. When I strip most of that down, it works. That's why I can't post any code example on Codepen or something similar.
Now my question is, is there any known issue with the UI-Router when using it with an authenticator, or maybe any other reason, why the ui-sref-opts won't reload the page?
Sorry for the kind of unspecific question, but maybe someone can help me out.
EDIT: More information and code
Ok, I'll try my best to give you the relevant information.
This is how my config.router.js is set up.
angular.module('app')
.run(
// Authenicator is in here
)
.config(
['$stateProvider', '$urlRouterProvider', 'JQ_CONFIG', '$authProvider',
function($stateProvider, $urlRouterProvider, JQ_CONFIG, $authProvider) {
// ...
.state('app.channel', {
url: '/projects/{projectId}/{channelId}',
views: {
'': {
templateUrl: 'tpl/channel/index.html'
}
},
resolve: {
deps: ['$ocLazyLoad',
function($ocLazyLoad) {
return $ocLazyLoad.load('angularFileUpload').then(
function() {
return $ocLazyLoad.load([
]);
}
);
}
]
}
})
// ...
}
]
);
It could depend on the directive cache-view="false"
. Usually, you have to put it on the <ion-view>
directive in the page you are going, in your case in tpl/channel/index.html
. But if you have nested view, you should put it in every view.
I had the same problem with a nested tab view. I had a series of tab and, inside one of them, another view with two tabs.
<ion-tabs class="tabs-icon-top tabs-color-active-positive">
<!-- Home Tab -->
<ion-tab title="MY FEED" icon-off="ion-ios-home-outline" icon-on="ion-ios-home" ui-sref="main.wall">
<ion-nav-view name="tab-wall"></ion-nav-view>
</ion-tab>
<!-- Messages Tab -->
<ion-tab title="MESSAGES" icon-off="ion-ios-email-outline" icon-on="ion-ios-email" ui-sref="main.message-tabs" ui-sref-opts="{reload: true, notify: true}">
<ion-nav-view name="tab-messages"></ion-nav-view>
</ion-tab>
</ion-tabs>
To make the reload work I had to put the directive cache-view="false"
both in the container
<ion-view cache-view="false">
<ion-tabs class="tabs-color-active-positive tabs-striped tabs-message tabs-top">
<!-- Message Tab -->
<ion-tab title="MESSAGES" ui-sref="main.message-threads" ui-sref-opts="{reload: true, notify: true}">
<ion-nav-view name="subtab-messages"></ion-nav-view>
</ion-tab>
<!-- Notification Tab -->
<ion-tab title="NOTIFICATIONS" ui-sref="main.notifications">
<ion-nav-view name="subtab-notifications"></ion-nav-view>
</ion-tab>
</ion-tabs>
and in the page
<ion-view view-title="Message Threads" class="threads" cache-view="false">
<ion-content class="has-tabs has-tabs-top">
...
这篇关于AngularJS,UI的SREF-OPTS无助重装应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!