2016-02-05 26 views
8

ho iniziato a testare il nuovo v1.0.0alpha0 ui-router con AngularJS v1.4.0 ma sto ottenendo questo errore:ui-router v1.0.0alpha0 - TypeError: Impossibile leggere la proprietà 'creationContext' undefined

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 --> 

Ecco il mio 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', 
      } 
     } 
    }; 

qualcuno ha idea di cosa potrebbe essere la causa di questo problema o come posso procedere per saperne di più circa il problema che non ho avuto nella 0.2 versione del router?

Grazie

risposta

2

Si sta verificando questo errore perché tenta di trovare un ui-view denominato subjects come genitore.

Imo è più semplice di fare proprio questo:

'[email protected]': { 

rivolge Assolutamente la vista 'info' nel contesto di 'home.details'.

così si può avere la seguente ui-view entro app/subjects/partials/subjects.html:

<div ui-view='intro'/> 

Tuttavia, se si fa vogliono punti nel nome ui-view leggere questo commento del 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 
*/ 

Quindi nel tuo caso credo che questo si applica:

'[email protected]': { 
+0

Grazie esaminerò questo e aggiornerò i miei risultati. –

+0

@Marilou qualche feedback su questo? – koox00

+0

Ci scusiamo per il ritardo nella risposta. Cercando di sistemare molti bug :-) Penso che ora sia tutto a posto. Proverò alcune cose diverse e posta un'altra domanda se ancora un problema. Grazie –

0

Poiché non hai fornito un esempio JSFiddle, è un po 'difficile da notare un errore nel codice. Tuttavia, ecco un similar question in cui la soluzione sta aggiungendo per prima cosa lo stato padre. Forse stai usando lo stesso concetto.

0

prima cosa vorrei provare a rimuovere la virgola qui:

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

..e se questo non ha fatto , proverei a cambiare

url: '/home/' a: url: '/home'

e

url: 'subjects' a: url: '/subjects'

Se ci fosse ancora un problema, mi piacerebbe:

  • Inizia esaminando come i vostri stati vengono generati da tali variabili - I non vedere dove vengono alimentati a $stateProvider.
  • Verificare che lo stato padre venga creato prima dello stato secondario.
Problemi correlati