2016-02-05 17 views
8

मैं AngularJS v1.4.0 के साथ नए ui रूटर v1.0.0alpha0 का परीक्षण करना शुरू कर दिया 'creationContext' पढ़ा नहीं जा सकता, लेकिन मैं इस त्रुटि हो रही है:ui रूटर v1.0.0alpha0 - लेखन त्रुटि: संपत्ति के अपरिभाषित

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 में नहीं मिला के बारे में अधिक जानने के लिए आगे बढ़ सकते हैं:

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 है राउटर का संस्करण?

धन्यवाद

उत्तर

2

आपको यह त्रुटि हो रही है क्योंकि यह को subjects नामक माता-पिता के रूप में ढूंढने का प्रयास करता है।

इमो यह सिर्फ यह करने के लिए सरल है:

'[email protected]': { 

बिल्कुल 'home.details' के संदर्भ में 'info' दृश्य निशाना बनाता है।

तो तुम app/subjects/partials/subjects.html भीतर निम्नलिखित ui-व्यू हो सकता है:

<div ui-view='intro'/> 

लेकिन अगर आप ऐसा करेंगे चाहते ui-view नाम पर डॉट्स ui-routersource से इस टिप्पणी को पढ़ें।

'[email protected]': { 
+0

धन्यवाद मैं इसमें देखता हूं और अपने निष्कर्षों को अपडेट करता हूं। –

+0

@Marilou इस पर कोई प्रतिक्रिया? – koox00

+0

उत्तर देने में देरी के लिए खेद है। बहुत सारी बग ठीक करने की कोशिश कर रहा है :-) मुझे लगता है कि यह ठीक है। कुछ अलग-अलग चीजों को आजमाएं और यदि कोई समस्या हो तो एक और प्रश्न पोस्ट करें। धन्यवाद –

0

चूंकि आप एक JSFiddle उदाहरण प्रदान नहीं किया है, यह आपके कोड में कोई त्रुटि दिखाई करने के लिए थोड़ा मुश्किल है। हालांकि यहां एक similar question है जहां समाधान पहले मूल स्थिति जोड़ रहा है। शायद आप एक ही अवधारणा का उपयोग कर रहे हैं।

0

सबसे पहले मैं यहाँ अल्पविराम को दूर करने की कोशिश करेंगे:

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

..और है कि अगर ऐसा नहीं किया

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

तो आपके मामले में मैं इस पर लागू होता है लगता है यह, मैं

url: '/home/' को बदलने की कोशिश करता हूं: url: '/home'

और

url: 'subjects' रहे हैं: url: '/subjects'

अगर वहाँ अभी भी एक समस्या थी, मैं चाहते हैं:

  • प्रारंभ कैसे अपने राज्यों वे चर से उत्पन्न किया जा रहा है की जांच कर रहे हैं - मैं यह नहीं देखें कि उन्हें $stateProvider पर खिलाया जा रहा है।
  • सत्यापित करें कि मूल स्थिति बच्चे के राज्य के सामने बनाई गई है।
संबंधित मुद्दे