gpt4 book ai didi

javascript - $state.reload() 移动到父级的 $state

转载 作者:行者123 更新时间:2023-11-28 05:41:56 26 4
gpt4 key购买 nike

我正在实现某种动态工作流程,当达到某个点时,我必须重新加载状态以呈现 HTML 并重新实例化 Controller 才能继续。

我发现我第二次调用 $state.reload() 不起作用。这是期望的行为吗?我可以做什么来强制重新加载?

if(advanceComplexAction()) {
console.log(self.$state); //This is always been printed in console
self.$state.reload();
}
else {
closeActionWizard();
}

我正在检查我的控制台,console.log 总是被打印,但我的语句 self.$state.reload() 仅在我第一次调用它时正确运行。

编辑:

我注意到,当我第一次重新加载时,我的网址发生了变化,并且正在更改为父网址。这一定是问题所在,因为第三次它只重新加载parentState。我不知道如何解决这个问题

第一次正常工作时,我的网址是:

http://localhost:1234/app/parentstate/childstate

使用重新加载并且一切正常后,它会移动到父状态。

http://localhost:1234/app/parentstate

因此,当我再次重新加载时,它只会重新加载父 View 。我定义我的路线如下。

.config(function($stateProvider, modalStateProvider){
$stateProvider

.state('app.parentstate',
modalStateProvider.create({
animation: true,
name: 'app.parentsate',
url: 'apps/parentstate',
controllerAs: 'parentCtrl',
controller: 'ParentCtrl',
windowClass: 'semi-modal semi-modal--XXL',
templateUrl: function() {
return 'app/ui/apps/parent/parent.html';
},
resolve: {
//Some resolve function
}]
}
})
)
.state('app.parentstate.childstate',
modalStateProvider.create({
animation: true,
name: 'app.parentstate.childstate',
url: '/childstate',
controllerAs: 'childWizardCtrl',
controller: 'ChildWizardCtrl',
windowClass: 'semi-modal semi-modal--XL',
templateUrl: function(){
return 'app/ui/apps/child/child.html';
}
})
)

谢谢

最佳答案

也许你应该尝试类似的东西

$state.transitionTo('current_state', null, {'reload':true});

关于javascript - $state.reload() 移动到父级的 $state,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38851206/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com