[英]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.