0
我無法運行,由於應用程序錯誤「錯誤:重複的參數名稱模式‘身份證’‘/實例/:ID /實例/:ID /編輯’」
JS
routerApp.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/home');
$stateProvider
.state('home', {
url : '/home',
templateUrl : 'home-view.html',
controller : 'homeController'
})
.state('instance', {
url : '/instance/:id',
templateUrl : 'data-view.html',
controller : 'instanceController'
})
.state('instance.edit', {
url: '/instance/:id/edit',
templateUrl : 'edit-table.html',
controller : 'instanceEditController'
});
});
routerApp.controller('homeController', ['$scope', '$state', function($state, $scope) {
console.log("inside home controller");
}]);
routerApp.controller('instanceController', ['$scope', '$state', function($state, $scope) {
console.log("inside instance view controller");
$scope.data = [
{
"Name" : "Hello"
}
]
}]);
routerApp.controller('instanceEditController', ['$scope', '$state', function($state, $scope) {
console.log("inside instance edit controller");
}]);
如何在狀態之間傳遞數據?我目前使用
<a ui-sref=".edit{{'id' : 2, 'data' : data}}" class="btn btn-primary">Instance View</a>
Plnkr:http://plnkr.co/edit/IMOYLn8dFzGM4p9OB7My?p=preview