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

前端之家收集整理的这篇文章主要介绍了angularjs – ui-router v1.0.0alpha0 – TypeError:无法读取未定义的属性’creationContext’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我开始用AngularJS v1.4.0测试新的ui-router v1.0.0alpha0,但是我收到了这个错误
  1. TypeError: Cannot read property 'creationContext' of undefined
  2. at http://localhost:1828/lib/angular-ui-router/release/angular-ui-router.js:1573:65
  3. at curried (http://localhost:1828/lib/angular-ui-router/release/angular-ui-router.js:128:24)
  4. at http://localhost:1828/lib/angular-ui-router/release/angular-ui-router.js:130:21
  5. at Array.filter (native)
  6. at matchingConfigPair (http://localhost:1828/lib/angular-ui-router/release/angular-ui-router.js:1587:48)
  7. at Array.map (native)
  8. at $View.sync (http://localhost:1828/lib/angular-ui-router/release/angular-ui-router.js:1597:53)
  9. at $View.register [as registerUiView] (http://localhost:1828/lib/angular-ui-router/release/angular-ui-router.js:1605:15)
  10. at http://localhost:1828/lib/angular-ui-router/release/angular-ui-router.js:3741:37
  11. at invokeLinkFn (http://localhost:1828/lib/angular/angular.js:8604:9) <!-- uiView: subjects.intro -->

这是我的app.config:

  1. var home = {
  2. name: 'home',template: '<div data-ui-view></div>',url: '/home/'
  3. };
  4.  
  5. var homeSubjects = {
  6. name: 'home.subjects',resolve: {
  7. getSubjects: ['subjectService',(sus: ISubjectService) => {
  8. console.log("getSubjects");
  9. sus.getSubjects();
  10. return true;
  11. }]
  12. },url: 'subjects',views: {
  13. '': {
  14. templateUrl: 'app/subjects/partials/subjects.html',},'subjects.intro@home.subjects': {
  15. templateUrl: 'app/subjects/partials/subjects_intro.html','subjects.auth@home.subjects': {
  16. templateUrl: 'app/subjects/partials/subjects_auth.html',}
  17. }
  18. };

有没有人知道可能导致这个问题的原因,或者我如何继续找到更多关于我在路由器的0.2版本中没有得到的问题?

谢谢

您遇到此错误,因为它尝试查找名为subject的ui-view作为父级.

Imo这样做更简单:

  1. 'intro@home.subjects': {

绝对瞄准’home.details’上下文中的’info’视图.

所以你可以在app / subjects / partials / subjects.html中拥有以下ui-view:

  1. <div ui-view='intro'/>

但是,如果您确实需要ui-view名称中的点,请从ui-router source中读取此注释.

  1. /*
  2. * If the ViewConfig's target ui-view name is a segmented name (with dots),then a ui-view matches if:
  3. * - There exists a parent ui-view where:
  4. * - the parent ui-view's name matches the first segment (index 0) of the ViewConfig's target name
  5. * - the parent ui-view's context matches the ViewConfig's anchor
  6. * - And the remaining segments (index 1..n) of the ViewConfig's target name match the tail of the ui-view's fqn
  7. */

所以在你的情况下,我猜这适用:

  1. '$default.intro@home.subjects': {

猜你在找的Angularjs相关文章