Javascript Angularjs[';ui路由';]在父级和子级中使用不同的布局
让我们说; 状态:/profile(父级)我想显示彼此相邻的3列左窗格内容右窗格 state/profile/{id}我想在左窗格和内容中显示两列 到目前为止,我已经完成了这段代码,但它并没有按照我想要的方式工作Javascript Angularjs[';ui路由';]在父级和子级中使用不同的布局,javascript,angularjs,frameworks,angular-ui-router,Javascript,Angularjs,Frameworks,Angular Ui Router,让我们说; 状态:/profile(父级)我想显示彼此相邻的3列左窗格内容右窗格 state/profile/{id}我想在左窗格和内容中显示两列 到目前为止,我已经完成了这段代码,但它并没有按照我想要的方式工作 .state('test', { url: "/test", views: { "main": { templateUrl:"app/views/templa
.state('test', {
url: "/test",
views:
{
"main":
{
templateUrl:"app/views/templates/test/test.php",
controller:function($scope, $stateParams)
{
console.log("bum");
console.log($stateParams.id); //this is undefined even if i have it defined!
}
}
}
})
.state('test.id',
{
url:"/{id}",
views:{
"main":{
templateUrl:"app/views/templates/test/testOverWritten.php",
controller:function($scope, $stateParams)
{
console.log("main is overwritten");
console.log($stateParams.id);
}
},
"testLeft":
{
templateUrl:"app/views/templates/test/test.menu.php",
controller:function($scope)
{
console.log("insantieted");
}
},
"testContent":
{
templateUrl:"app/views/templates/test/test.content.php",
controller:function($scope)
{
console.log("insantieted");
}
}
}
})
父索引
有
集成到main中的test.php
<div class="row">
<div class="col-md-8">
<div ui-view="testContent">Original</div>
</div>
<div class="col-md-3">
<div ui-view="testLeft">OrgMenu</div>
</div>
</div>
我将视图引导到错误的路径,使用viewname@statename带来了链接中解释的解决方案
解决了听起来你们两个州没有共享任何东西(除了url)?这是正确的吗?我传递任何数据的目的不是为了测试,只是为了确保我有正确的结构。所以是的,只有URL和嵌套视图@Nix
.state('test.id',
{
url:"/{id}",
views:{
"main@":{
templateUrl:"app/views/templates/test/layout2.php",
controller:function($scope, $stateParams)
{
console.log("main is overwritten");
console.log($stateParams.id);
}
},
"testMenu@test.id":
{
templateUrl:"app/views/templates/test/test.menu.php",
controller:function($scope)
{
console.log("instantieted");
}
},
"testContent@test.id":
{
templateUrl:"app/views/templates/test/test.content.php",
controller:function($scope)
{
console.log("instantieted");
}
}
}
})