鉴于以下...
.html
<form (ngSubmit) = "onSubmit()"
#heroForm = "ngForm">
{{diagnostic}}
<div class = "form-group">
<label for = "name">Name</label>
<input type = "text"
class = "form-control"
required
[(ngModel)] = "model.name"
ngControl = "name"
#name = "ngForm"
#spy>
<p *ngIf = "name.dirty"
class = "alert alert-danger">
Name is required
</p>
<!--<p [hidden] = "name.dirty"-->
<!--class = "alert alert-danger">-->
<!--Name is required-->
<!--</p>-->
</div>
..
..是否有可能得到#name = "ngForm"
(ngForm) .dart 组件中的引用允许操作?欢迎任何建议和指正。
导入这个-
import {ViewChild} from 'angular2/core';
只需将此字段与注释添加到类中即可
// Dart syntax
@ViewChild('heroForm') NgForm heroForm;
但您不能在构造函数中使用它,因为它只是稍后设置。在ngAfterViewInit
或用户输入的事件处理程序,您可以不受限制地使用它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)