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 に答える