matth3o matth3o - 1 year ago 141
Dart Question

dart angular2 - form directive #mymodel="ngForm" not working

When I put in my template something like

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

I cannot start my application, I have the following message :

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]:
'i2' has no member named 'initReflector'.

If I remove the attribute
it works.

My pubspec.yml :

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

I looked at this repo ( which works fine, but I cannot see any differences.

Thanks for your help !

Answer Source

I found it!

The tag #property="ngForm" only works if the property is wrapped into a bean acting as the model. If the property is just in the component, it doesn't work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download