Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 角度ui路由器状态问题_Javascript_Angularjs_Angular Ui Router - Fatal编程技术网

Javascript 角度ui路由器状态问题

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

我目前正在尝试在我的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',
  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:)