Javascript 角度ui路由器状态问题
我目前正在尝试在我的angular应用程序中设置路由。 我有以下几个州:Javascript 角度ui路由器状态问题,javascript,angularjs,angular-ui-router,Javascript,Angularjs,Angular Ui Router,我目前正在尝试在我的angular应用程序中设置路由。 我有以下几个州: .state('pet', { url: '/pet/:petId', templateUrl: 'scripts/views/profile/profile.html', controller: 'ProfileCtrl' }) .state('addPet', { url: '/pet/add', templateUrl: 'scripts/views/profile/edit.html', c
.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试图调用'pet'状态,并将'add'作为:petId'参数
所以我试着用另一种方式:
.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'
})
而且根本不起作用
有什么建议吗?改变顺序,在pet状态之前保持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'
})
谢谢A.J,你让我开心。不客气@Mencls,你可以随时指望stackoverflow:)