1

我有一个 $state 配置如下:

.state('app.subjects.current', {
    abstract: true,
    url: "/:subjectId",
    template: "<div ui-view />",
    ncyBreadcrumb: {
        skip: true
    }
})
.state('app.subjects.current.home', {
    url: '/home',
    templateUrl: "assets/src/subject/subjectHome.html",
    resolve: loadSequence('subjectHomeCtrl'),
    ncyBreadcrumb: {
        label: 'View'
    },
    string: 'sidebar.nav.pages.SUBJECTHOME'
})

我使用 $state.go('app.subjects.current.home', {subjectId: '999'}); 转换到这个状态。

url 在地址栏中显示为“<a href="http://localhost:12253/#/app/subjects//home?subjectId=999" rel="nofollow">http://localhost:12253/# /app/subjects//home?subjectId=999”。它实际上应该是“<a href="http://localhost:12253/#/app/subjects/999/home" rel="nofollow">http://localhost:12253/#/app/subjects/999 /家”。

谢谢你的帮助。

4

1 回答 1

0

我创建了具有完全相同映射的工作示例- 向您展示您的方法有效

所以,这些是状态

    .state('app', {
      template: '<div ui-view=""></div>',
    })
    .state('app.subjects', {
      template: '<div ui-view=""></div>',
    })
    .state('app.subjects.current', {
      abstract: true,
      url: "/:subjectId",
      template: "<div ui-view />",
      ncyBreadcrumb: {
        skip: true
      }
    })
    .state('app.subjects.current.home', {
      url: '/home',
      templateUrl: "assets/src/subject/subjectHome.html",
      //resolve: loadSequence('subjectHomeCtrl'),
      ncyBreadcrumb: {
        label: 'View'
      },
      string: 'sidebar.nav.pages.SUBJECTHOME'
    })

这样我们就可以调用它们

// $state.go
<button ng-click="$state.go('app.subjects.current.home', {subjectId: '999'});">

// ui-sref
<a ui-sref="app.subjects.current.home({subjectId: '888'})">

在这里检查。它应该有助于找出您的应用程序中有什么不同...

于 2015-02-22T12:57:50.037 回答