我开始用AngularJS v1.4.0测试新的ui-router v1.0.0alpha0,但是我收到了这个错误:
- 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',},'subjects.intro@home.subjects': {
- templateUrl: 'app/subjects/partials/subjects_intro.html','subjects.auth@home.subjects': {
- templateUrl: 'app/subjects/partials/subjects_auth.html',}
- }
- };
有没有人知道可能导致这个问题的原因,或者我如何继续找到更多关于我在路由器的0.2版本中没有得到的问题?
谢谢
您遇到此错误,因为它尝试查找名为subject的ui-view作为父级.
Imo这样做更简单:
- 'intro@home.subjects': {
绝对瞄准’home.details’上下文中的’info’视图.
所以你可以在app / subjects / partials / subjects.html中拥有以下ui-view:
- <div ui-view='intro'/>
但是,如果您确实需要ui-view名称中的点,请从ui-router source中读取此注释.
- /*
- * 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
- */
所以在你的情况下,我猜这适用:
- '$default.intro@home.subjects': {