【发布时间】:2016-08-12 13:06:54
【问题描述】:
ui-view 不适用于 ui-tab。请查看场景,并请告诉我我错在哪里。
在客户页面中,我正在调用页面更新客户,通过单击任何客户customers.view.html,此页面包含客户列表。当我点击任何客户时,它会打开类似以下 url 的链接。 http://localhost:3000/home/#/updatecustomer/5
customers.view.html
<a><i ui-sref="home.updatecustomer({ customerId: {{customer.id}} })" class="fa fa-edit pull-right" ng-click="$event.stopPropagation()"></i></a>
在配置中,我正在创建 url http://localhost:3000/home/#/updatecustomer/5,我可以打开页面 index.html,但是查看相应的配置文件和设置没有打开...
请看类似的工作演示,Working DEMO
“配置”
.state('home.updatecustomer', {
url: 'updatecustomer/:customerId',
views:{
'':{
templateUrl: 'addcustomer/index.html',
controller: 'TabsDemoCtrl',
},
'profile':{
templateUrl: 'addcustomer/profile.html'
},
'setting':{
templateUrl: 'addcustomer/setting.html'
},
}
})
控制器
var app = angular.module('app') ;
app.controller('TabsDemoCtrl', TabsDemoCtrl);
TabsDemoCtrl.$inject = ['$scope', '$state'];
function TabsDemoCtrl($scope, $state){
$scope.tabs = [
{ title:'profile', view:'profile', active:true },
{ title:'setting', view:'setting', active:false }
];
}
index.html
<uib-tabset active="active">
<uib-tab ng-repeat="tab in tabs" heading="{{tab.title}}" active="tab.active" disable="tab.disabled">
<div ui-view="{{tab.view}}"></div>
</uib-tab>
</uib-tabset>
profile.html
<div>profile of customer </div>
Setting.html
<div>Setting for customer </div>
【问题讨论】:
-
从 ui-view 中删除括号,它不需要。不知道是不是这个问题……
-
@GustavoGabriel 我删除但仍然无法正常工作,我认为这不会有任何问题,因为在工作演示中,我们使用的是相同的东西......
-
@geeks 你能在你的 plunkr 中添加配置吗??
标签: javascript html angularjs