我有一个显示联系人列表的页面,点击视图中的某个联系人应切换到详细状态,如下所示:
仪表板触点-controller.js
vm.viewContact = function(contactId) {
console.log("Load contact " + contactId);
$state.go("app.dashboards_contact", {"id": contactId});
}
触点-module.js
.state('app.dashboards_contact', {
url: '/dashboard-contact/:id',
views: {
'content@app': {
templateUrl: 'app/main/apps/dashboards/contacts/about/about.html',
controller: 'DashboardContactController as vm'
}
},
resolve: {
contact: ['DashboardContactsDataService', function($stateParams, DashboardContactsDataService) {
console.log($stateParams.id);
return DashboardContactsDataService.get($stateParams.id);
}
]
},
bodyClass: 'dashboard-contact'
});
解析中的$ stateParams.id始终未定义。
答案 0 :(得分:1)
你没有在解决方案中注入$ stateParams。不应该
resolve: {
contact: ['$stateParams', DashboardContactsDataService', function($stateParams, DashboardContactsDataService) {
console.log($stateParams.id);
return DashboardContactsDataService.get($stateParams.id);
}
]
},