Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 导入anuglar2/forms导致;无法读取属性';注释';“未定义”的定义;_Javascript_Ecmascript 6_Angular_Atscript - Fatal编程技术网

Javascript 导入anuglar2/forms导致;无法读取属性';注释';“未定义”的定义;

Javascript 导入anuglar2/forms导致;无法读取属性';注释';“未定义”的定义;,javascript,ecmascript-6,angular,atscript,Javascript,Ecmascript 6,Angular,Atscript,我正试图创建中所述的简单表单,但当我添加 从'angular2/forms'导入{forms,required} 与 TypeError: Cannot read property 'annotations' of undefined TypeError: Cannot read property 'annotations' of undefined at ReflectionCapabilities.System.register.execute.$__export.annotati

我正试图创建中所述的简单表单,但当我添加

从'angular2/forms'导入{forms,required}

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
我无法理解错误消息的含义,也无法找到forms指令定义的位置


更新:“undefined”实际上是一个“forms”指令,它在angular2/modules/angular2/src/forms中似乎真的缺失了。然后DirectiveMetadataReader将“未定义”进一步传递给反射器,最终导致异常。最好有一个签入模板。

看起来Victor博客中的示例与您使用的版本不匹配(那些日子API变化太快了)。但现在beta版已经发布(这意味着不再有突破性的更改),所以我创建了一个功能尽可能接近的工作示例:

角度2β

import {Component} from 'angular2/core'
import {ControlGroup, FormBuilder, Validators} from 'angular2/common'
...
只是为了检查它走了多远(足够远!)

角度版本:2.0.0-rc.1

所有使用angular2的导入都需要更改为@angular

import {Component} from '@angular/core'
import {ControlGroup, FormBuilder, Validators} from '@angular/common';
有关导入的更多列表,请参见此处:-


我完全不理解这个问题;您链接的文章不是生产代码,文章明确指出“(这是建议的API,我们很乐意听取您的意见。)”这告诉我,它不是工作代码,而是作者希望使用的语法建议。公平地说,除了那一句话之外,本文的其余部分将它作为功能性工作代码而不仅仅是一些建议的概念。你找到解决这个问题的方法了吗?没有。据我所知,它还没有完成。至少angular2/modules/angular2/src/forms/directions.js#ControlDirective.controlOrName在构造函数中被设置为null,并且从未更新,这使得"U控件返回null,然后使用NPE失败。“angular2/forms”中没有任何“forms”导出,但您可以逐个导入所有内容:从“angular2/forms”导入{ControlGroupDirective、ControlDirective、CheckboxControlValueAccessor、DefaultValueAccessor};到目前为止,只有Angular2 RC.1没有RC.2@OUtlookerEdited.my bad..tanx@PardeepJain