微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

angularjs – ui-router v1.0.0alpha0 – TypeError:无法读取未定义的属性’creationContext’

我开始用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': {

原文地址:https://www.jb51.cc/angularjs/142026.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐