gpt4 book ai didi

angularjs - ui-router v1.0.0alpha0 - TypeError : Cannot read property 'creationContext' of undefined

转载 作者:行者123 更新时间:2023-12-04 08:48:01 25 4
gpt4 key购买 nike

我开始使用 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 版路由器中没有遇到的问题的更多信息?

谢谢

最佳答案

您遇到此错误是因为它试图查找 ui-view命名 subjects作为家长。

Imo 这样做更简单:

'intro@home.subjects': {

绝对针对 'info''home.details' 的上下文中查看.

所以你可以在 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': {

关于angularjs - ui-router v1.0.0alpha0 - TypeError : Cannot read property 'creationContext' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35220208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com