2015-03-23 22 views
7

Ich versuche, einfache Form zu schaffen, wie in http://angularjs.blogspot.no/2015/03/forms-in-angular-2.html beschrieben, "Can not Eigenschaft 'Anmerkungen' undefinierten lesen", aber wenn ich hinzufügenImportieren anuglar2/forms verursacht

import {forms, required} from 'angular2/forms';

in Abstürzen mit

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 

Kann nicht verstehen, was diese Fehlermeldung bedeutet, und ich kann auch nicht finden, wo diese Formular-Direktive definiert ist.

AKTUALISIERUNG: Die 'undefined' ist eigentlich eine 'Forms' Direktive, die in angular2/modules/angular2/src/forms wirklich fehlt. Dann übergibt DirectionalMetadataReader das 'undefined' weiter an den Reflektor, was schließlich zu einer Ausnahme führt. Wäre schön, ein Check-in Template zu haben.

+0

Ich verstehe diese Frage nicht genau; der Artikel, den Sie verlinkt haben, ist kein Produktionscode, der Artikel sagt eindeutig "(Dies ist eine vorgeschlagene API, wir würden gerne Ihre Eingabe dazu nehmen.)" Das sagt mir, dass es nicht Code funktioniert, sondern ein Vorschlag für die Syntax des Autors gerne benutzen. – Claies

+0

um fair zu sein, anders als diese einzelne Aussage der Rest des Artikels präsentiert es als funktionale Arbeitscode nicht nur einige vorgeschlagene Konzept – adeelmahmood

+0

haben Sie eine Lösung für dieses Problem gefunden? – jumpa

Antwort

2

Es sieht so aus, als ob das Beispiel von Victors Blog nicht mit der Version übereinstimmt, die Sie verwendet haben (APIs haben sich in diesen Tagen so schnell geändert). Aber jetzt Beta freigegeben wird (und es bedeutet nicht mehr Bruch Änderungen), so habe ich Beispiel erstellt die Arbeit mit so nah wie möglich Funktionalität:

Angular 2 Beta

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

http://plnkr.co/edit/ae1WEgQJWPMdEgoweMGd?p=preview nur zu prüfen, wie weit ging es (weit genug!).

Von abgewinkelte Ausführung: 2.0.0-rc.1

Alle Importe, die angular2 geändert werden müssen wurden unter Verwendung von @angular

import {Component} from '@angular/core' 
import {ControlGroup, FormBuilder, Validators} from '@angular/common'; 

Weitere Liste der Importe siehe hier: -

+0

bis jetzt gibt es nur Angular2 RC.1 nicht RC.2 @OUtlooker –

+0

Edited.my schlecht..tanx @PardeepJain – Outlooker

+0

Ihre Begrüßung @Outlooker –