dart angular2 - 表格指令#mymodel =" ngForm"不工作

时间:2016-09-05 10:07:09

标签: forms angular dart

当我输入类似

的模板时
 <input id="password" name="password" class="form-control" type="password" [(ngModel)]="password" ngControl="password" #password="ngForm" required minlength="6" maxlength="30">

我无法启动我的应用程序,我有以下消息:

 Can't read 'package:website/login_component.template.dart' (Could not find asset website|lib/login_component.template.dart.).
 import 'package:website/login_component.template.dart' as i2;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Warning from Dart2JS on atthecorner_website|web/main.dart]:
web/main.template.dart:33:1:
'i2' has no member named 'initReflector'.
i2.initReflector();
^^^^^^^^^^^^^^^^^^

如果删除属性#password="ngForm",则可以使用。

我的pubspec.yml:

name: website
description: website
version: 0.0.1
environment:
  sdk: ">=1.13.0 <2.0.0"
dependencies:
  angular2: 2.0.0-beta.20
  browser: ^0.10.0
  dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular2:
    platform_directives:
    - 'package:angular2/common.dart#COMMON_DIRECTIVES'
    - 'package:angular2/common.dart#FORM_DIRECTIVES'
    platform_pipes:
    - 'package:angular2/common.dart#COMMON_PIPES'
    entry_points: web/main.dart
- dart_to_js_script_rewriter

我查看了这个回复(https://github.com/angular-examples/forms)并且工作正常,但我看不出任何差异。

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

我找到了!

标签#property="ngForm"仅在property被包装到充当模型的bean中时才有效。如果属性只在组件中,则不起作用。