导入anuglar2 /形式引起"不能读取属性未定义的&QUOT的'注释'; [英] Importing anuglar2/forms causing "Cannot read property 'annotations' of undefined"

查看:495
本文介绍了导入anuglar2 /形式引起"不能读取属性未定义的&QUOT的'注释';的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建在 HTTP描述简单的形式://angularjs.blogspot.no/2015/03/forms-in-angular-2.html ,但是当我添加

I'm trying to create simple form as described in http://angularjs.blogspot.no/2015/03/forms-in-angular-2.html, but when I add

进口{形式,需要从}'angular2 /表格';

在崩溃

TypeError: Cannot read property 'annotations' of undefined

TypeError: Cannot read property 'annotations' of undefined
    at ReflectionCapabilities.System.register.execute.$__export.annotations (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/reflection/reflection_capabilities.es6!eval:81:40)
    at Reflector.System.register.execute.$__export.annotations (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/reflection/reflector.es6!eval:81:50)
    at DirectiveMetadataReader.System.register.execute.$__export.read (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/compiler/directive_metadata_reader.es6!eval:31:41)
    at eval (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/compiler/compiler.es6!eval:127:35)
    at Array.map (native)
    at Function.System.register.execute.$__export.map (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/facade/collection.es6!eval:172:26)
    at Compiler.System.register.execute.$__export.createSteps (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/compiler/compiler.es6!eval:126:43)
    at Compiler.System.register.execute.$__export._compileTemplate (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/compiler/compiler.es6!eval:164:53)
    at eval (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/compiler/compiler.es6!eval:154:29)
    at Zone.run (http://localhost:9090/node_modules/zone.js/zone.js:87:19)

-----async gap-----
Error
    at Function.System.register.execute.$__export.then (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/facade/async.es6!eval:35:28)
    at Compiler.System.register.execute.$__export._compile (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/compiler/compiler.es6!eval:153:42)
    at Compiler.System.register.execute.$__export.compile (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/compiler/compiler.es6!eval:134:34)
    at eval (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/application.es6!eval:73:23)
    at Function.System.register.execute.$__export.apply (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/facade/lang.es6!eval:317:23)

-----async gap-----
Error
    at _AsyncInjectorStrategy.System.register.execute._AsyncInjectorStrategy.instantiate (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/di/injector.es6!eval:297:17)
    at Injector.System.register.execute.$__export._getByKey (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/di/injector.es6!eval:138:33)
    at Injector.System.register.execute.$__export.asyncGet (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/di/injector.es6!eval:112:25)
    at eval (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/application.es6!eval:113:39)

-----async gap-----
Error
    at VmTurnZone.System.register.execute.$__export._createInnerZone (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/zone/vm_turn_zone.es6!eval:61:45)
    at new VmTurnZone (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/zone/vm_turn_zone.es6!eval:29:34)
    at _createVmZone (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/application.es6!eval:101:16)
    at bootstrap (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/application.es6!eval:110:16)
    at y.main (http://localhost:9090/app.js!eval:10:12)
    at http://localhost:9090/?:42:21

-----async gap-----
Error
    at VmTurnZone.System.register.execute.$__export._createInnerZone (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/zone/vm_turn_zone.es6!eval:61:25)
    at new VmTurnZone (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/zone/vm_turn_zone.es6!eval:29:34)
    at _createVmZone (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/application.es6!eval:101:16)
    at bootstrap (http://localhost:9090/node_modules/angular/dist/js/prod/es6/angular2/src/core/application.es6!eval:110:16)
    at y.main (http://localhost:9090/app.js!eval:10:12)
    at http://localhost:9090/?:42:21

能不明白,错误消息意味着什么,我也找不到哪里是形式的指令定义。

Can't understand what that error message means, and I also can't find where is that forms directive defined.

更新:未定义实际上是一种形式指令,它似乎在angular2 /模块/ angular2 / src目录/形式真的错过。然后DirectiveMetadataReader通过了未定义进一步反射并最终导致异常。会是不错的模板进行检查。

UPDATE: the 'undefined' is actually a 'forms' directive which seems to be really missing in angular2/modules/angular2/src/forms. Then DirectiveMetadataReader passes the 'undefined' further to reflector which finally results in exception. Would be nice to have a check in Template.

推荐答案

它看起来像从维克多的博客不匹配您使用的版本的例子(API是改变这些天这么快)。但现在测试版发布(它意味着没有更多的重大更改),所以我创建工作以尽可能接近的功能例如:

It looks like the example from Victor's blog didn't match the version you used (APIs were changing so fast those days). But now beta is released (and it means no more breaking changes) so I've created working example with as close as possible functionality:

import {Component} from 'angular2/core'
import {ControlGroup, FormBuilder, Validators} from 'angular2/common'
...

http://plnkr.co/edit/ae1WEgQJWPMdEgoweMGd?p=$p$ PVIEW
只是为了检查它是如何远赴(远远不够!)。

http://plnkr.co/edit/ae1WEgQJWPMdEgoweMGd?p=preview just to check how far it went (far enough!).

这篇关于导入anuglar2 /形式引起"不能读取属性未定义的&QUOT的'注释';的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆