[英]angular ui-router state issue
我目前正在尝试在我的角度应用程序中设置路线。 我有以下状态:
.state('pet', {
url: '/pet/:petId',
templateUrl: 'scripts/views/profile/profile.html',
controller: 'ProfileCtrl'
})
.state('addPet', {
url: '/pet/add',
templateUrl: 'scripts/views/profile/edit.html',
controller: 'ProfileFormCtrl'
})
.state('editPet', {
url: '/pet/:petId/edit',
templateUrl: 'scripts/views/profile/edit.html',
controller: 'ProfileFormCtrl'
})
问题是当我想进入'addPet'状态时,angular试图使用'add'作为':petId'参数来调用'pet'状态。
所以我尝试用另一种方式来做:
.state('pet', {
url: '/pet',
abstract: true
})
.state('pet.show', {
url: '/:petId',
templateUrl: 'scripts/views/profile/profile.html',
controller: 'ProfileCtrl'
})
.state('pet.add', {
url: '/add',
templateUrl: 'scripts/views/profile/edit.html',
controller: 'ProfileFormCtrl'
})
.state('pet.edit', {
url: '/:petId/edit',
templateUrl: 'scripts/views/profile/edit.html',
controller: 'ProfileFormCtrl'
})
而且根本不起作用。
有什么建议么 ?
更改顺序,在宠物状态之前保持addPet状态
.state('addPet', {
url: '/pet/add',
templateUrl: 'scripts/views/profile/edit.html',
controller: 'ProfileFormCtrl'
})
.state('pet', {
url: '/pet/:petId',
templateUrl: 'scripts/views/profile/profile.html',
controller: 'ProfileCtrl'
})
.state('editPet', {
url: '/pet/:petId/edit',
templateUrl: 'scripts/views/profile/edit.html',
controller: 'ProfileFormCtrl'
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.