2016-02-05 5 views
8

の私は、AngularJSの1.4.0を使用して新しいUI-ルータv1.0.0alpha0をテストするために始めたが、私はこのエラーを取得しています:UI-ルータv1.0.0alpha0 - 例外TypeError:プロパティを読み取ることができません「creationContext」未定義

ここで
TypeError: Cannot read property 'creationContext' of undefined 
    at http://localhost:1828/lib/angular-ui-router/release/angular-ui-router.js:1573:65 
    at curried (http://localhost:1828/lib/angular-ui-router/release/angular-ui-router.js:128:24) 
    at http://localhost:1828/lib/angular-ui-router/release/angular-ui-router.js:130:21 
    at Array.filter (native) 
    at matchingConfigPair (http://localhost:1828/lib/angular-ui-router/release/angular-ui-router.js:1587:48) 
    at Array.map (native) 
    at $View.sync (http://localhost:1828/lib/angular-ui-router/release/angular-ui-router.js:1597:53) 
    at $View.register [as registerUiView] (http://localhost:1828/lib/angular-ui-router/release/angular-ui-router.js:1605:15) 
    at http://localhost:1828/lib/angular-ui-router/release/angular-ui-router.js:3741:37 
    at invokeLinkFn (http://localhost:1828/lib/angular/angular.js:8604:9) <!-- uiView: subjects.intro --> 

は私のapp.configです:

var home = { 
     name: 'home', 
     template: '<div data-ui-view></div>', 
     url: '/home/' 
    }; 

    var homeSubjects = { 
     name: 'home.subjects', 
     resolve: { 
      getSubjects: ['subjectService', 
       (sus: ISubjectService) => { 
        console.log("getSubjects"); 
        sus.getSubjects(); 
        return true; 
       }] 
     }, 
     url: 'subjects', 
     views: { 
      '': { 
       templateUrl: 'app/subjects/partials/subjects.html', 
      }, 
      '[email protected]': { 
       templateUrl: 'app/subjects/partials/subjects_intro.html', 
      }, 
      '[email protected]': { 
       templateUrl: 'app/subjects/partials/subjects_auth.html', 
      } 
     } 
    }; 

誰もがこの問題を引き起こすか、またはどのように私は0.2で取得していない問題についての詳細を調べるために進むことができかもしれないものの任意のアイデアを持っていますルータのバージョン?あなたはJSFiddle例を提供していないので

おかげ

答えて

2

subjectsという名前のui-viewを親として検索しようとしているため、このエラーが発生しています。

芋それだけでこれを行うに簡単です:

'[email protected]': { 

絶対に'home.details'の文脈で'info'ビューがターゲットに。

ですから、app/subjects/partials/subjects.html内で次のUIビューを持つことができます。

<div ui-view='intro'/> 

しかしあなたはがui-view名にドットをしたいですか場合はui-routersourceからこのコメントを読んで。

/* 
* If the ViewConfig's target ui-view name is a segmented name (with dots), then a ui-view matches if: 
* - There exists a parent ui-view where: 
* - the parent ui-view's name matches the first segment (index 0) of the ViewConfig's target name 
* - the parent ui-view's context matches the ViewConfig's anchor 
* - And the remaining segments (index 1..n) of the ViewConfig's target name match the tail of the ui-view's fqn 
*/ 

だからあなたの場合には、私は、これが適用されると思います:

'[email protected]': { 
+0

ありがとう、私はこれを調べ、私の発見を更新します。 –

+0

@Marilouこれに関するフィードバック? – koox00

+0

答えが遅れて申し訳ありません。たくさんのバグを修正しようとしました:-)今は大丈夫だと思います。いくつかの異なることを試み、まだ問題がある場合は別の質問を投稿します。ありがとう –

0

は、それはあなたのコード内の誤りに気づき少し難しいです。ただし、最初に親状態を追加するのはsimilar questionです。たぶんあなたは同じ概念を使っています。

0

まず、私はここにカンマを削除しようとするだろう:

templateUrl: 'app/subjects/partials/subjects_auth.html',

..andことはしなかった場合それを変更しようとします

url: '/home/'に:url: '/home'

url: 'subjects'へ:url: '/subjects'

まだ問題があった場合は、私がしたい:

  • スタートをあなたの状態は、これらの変数から生成されているかを検討して - I彼らがどこに供給されているのかを$stateProviderに見ないでください。
  • 子状態の前に親状態が作成されていることを確認します。
関連する問題