【发布时间】:2018-04-17 10:18:58
【问题描述】:
<form #subleaseForm01="ngForm">
<ng-template mdStepLabel>Fill out initial details</ng-template>
{{diagnostic}}
<md-grid-list cols="1" rowHeight="8:1">
<md-grid-tile>
<label for="title">Title</label>
<md-form-field>
<input mdInput type="text" id="title1" placeHolder="Title" class="form-control" required ngModel name="title" #name="ngModel"> TODO: remove this: {{model.title}}
</md-form-field>
<br>
<div [hidden]="name.valid || name.pristine">
Name is required
</div>
</md-grid-tile>
</md-grid-list>
<div>
<button md-raised-button color="warn" mdStepperNext>Next</button>
</div>
</form>
我想获取在标题字段中输入的值。我得到的只是未定义的。我正在使用 ngModel 标签来绑定变量。我编写了一个定义所需字段的类,并试图记录在提交当前值后创建的新对象。
【问题讨论】:
标签: angular data-binding angular-material angular4-forms