Angularjs 同一页上的3个控制器显示$state.is()的不同结果
首先,抱歉,我没有一个例子来说明。目前的情况是,我使用的是UI路由器,我有3个不同控制器的视图,每个视图位于同一页面上,状态名称为“result”。i、 e.标题、内容和侧栏 但是,当我调用Angularjs 同一页上的3个控制器显示$state.is()的不同结果,angularjs,Angularjs,首先,抱歉,我没有一个例子来说明。目前的情况是,我使用的是UI路由器,我有3个不同控制器的视图,每个视图位于同一页面上,状态名称为“result”。i、 e.标题、内容和侧栏 但是,当我调用$state.is('result')时,只有1个控制器(内容)返回true。我还尝试了$state.includes('result') 当我只记录$state时,所有3个的state对象在$state.current.name中显示相同的正确\result,但是,如果我尝试直接记录$state.curre
$state.is('result')
时,只有1个控制器(内容)返回true
。我还尝试了$state.includes('result')
当我只记录$state
时,所有3个的state对象在$state.current.name
中显示相同的正确\result
,但是,如果我尝试直接记录$state.current
,其中2个的名称将变为空白
我尝试交换视图的顺序,但只有内容返回true
我看了很多次医生,但我找不到原因。请帮忙
.state('result', {
url: '/result',
views: {
'headView' : {
templateUrl: 'modules/core/templates/head.html'
},
'contentView' : {
templateUrl: 'modules/core/templates/content.html'
},
'sidebarView' : {
templateUrl: 'modules/core/templates/sidebar.html'
},
}
})
将控制器放置在定义模板URL
的状态视图定义中
例如
.state('result', {
url: '/result',
views: {
'headView' : {
templateUrl: 'modules/core/templates/head.html',
controller: 'HeadViewController',
},
'contentView' : {
templateUrl: 'modules/core/templates/content.html',
controller: 'ContentViewController'
},
'sidebarView' : {
templateUrl: 'modules/core/templates/sidebar.html',
controller: 'SidebarViewController'
},
}
})