以下是我的应用程序结构的子集以及模态结构。应用结构:
.state ('A',{
abstract: true,
sticky:true,
views:{
'@ ':{
template:'<div ui-view="container-a"></div> <div ui-view="container-b"></div>', controller: BController
}
}
})
//A 的子项,在同一配置文件中定义为点表示法 (.)
.state(A.a,{
views:{
'container-a':{templateUrl:'some.html'},
'container-b':{templateUrl:'anothertemplte.html'}
}
});
在我的第二个配置文件中,我有类似的状态配置,但这里的状态 B 是状态 A.a 的子级,它由父属性定义,因为我不想有代表继承层次结构的长字符串(A.a.B 等,因为我有一系列类似嵌套的状态)
.state ('B',{
abstract: true,
parent: 'A.a',
views:{
'@':
{
template: <div ui-view="abc"></div><div ui-view="xyz"> /div>,
controller:BController
}
}
})
.state(B.b,{
views:{
'abc':{templateUrl:'some.html'},
'xyz':{templateUrl:'anothertemplte.html'}
}
});
模态结构:我有一个抽象的全局模式,有一个关闭按钮和一个 ui-sref 托管,里面有其他模板,如下所示:
$stateProvider
.state('global-modal',{
url: '',
abstract: true,
onEnter: ['$modal', function($modal) {
$modal.open({
template: '<html for close button> <div ui-sref="childModal" ',
controller: 'GlobalController',
backdrop:'static',
keyboard:false
})
}]
})
.controller('GlobalController', ['$scope', '$state', '$previousState', '$modalInstance',
function ($scope, $state, $previousState, $modalInstance) {
$previousState.memo("modalInvoker");
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
$previousState.go("modalInvoker");
};
}]);
然后有一个 2 个嵌套状态,它在 ui-view=childModal 中加载全球模态,如下所示(简言之)
state( 'C',{
parent: global-mdoal,
views:{'childModal':{template:'C_template.html', controller: 'CController' } }
})
state('D',{
parent: C,
views:{'childModal':{template:'D_template.html', controller: 'DController' } }
现在的问题:
如果我处于 B.b 状态并打开模态,它将加载 C,通过关闭它,粘性工作正常,但如果再次从 B.b 打开模态,这次从 C 导航到背景后面的子状态 D,它将导航到我的父状态 (A.a) 关闭模态的人将导航到 B.b,但它会刷新页面。(如果我在 A.a 之上从 C 到 D 的模态中进行此导航,这是我的顶级状态,它不会刷新页面,因为从 C 到 D 的导航总是在背景后面加载 A.a,因此在顶部状态 A.a 之上进行模态过渡时没有刷新,但在 A.a 的子状态(如 B.b 等)之上的模态内过渡会导致引用和粘性不会工作[甚至尝试将粘性:在每个状态下为真,但再次相同的行为]
C 状态你定义了"golbal-mdoal" 检查你的代码是错误的还是你在这里输入错误