我尝试在 Angular2 中验证输入时出错

Errors when I try to validate input in Angular2

我正在尝试验证输入

    <md-input-container class="name-input">
                <input type="text" mdInput [(ngModel)]="tileName"  #tileNameInput="ngModel" 
                      id="tileNameInput" name="tileNameInput" 
                      required placeholder="{{ 'Name' | translate }}"/>
                <md-error *ngIf="v.errors.required">Tile Name is required</md-error>
            </md-input-container>

我得到错误:

ERROR TypeError: Cannot read property 'errors' of undefined at Object.eval [as updateDirectives] (HeaderComponent.html:104) at Object.debugUpdateDirectives [as updateDirectives] (core.es5.js:12784) at checkAndUpdateView (core.es5.js:12122) at callViewAction (core.es5.js:12485) at execEmbeddedViewsAction (core.es5.js:12443) at checkAndUpdateView (core.es5.js:12123) at callViewAction (core.es5.js:12485) at execComponentViewsAction (core.es5.js:12417) at checkAndUpdateView (core.es5.js:12128) at callViewAction (core.es5.js:12485)

有人可以帮助我吗?

使用输入字段的名称代替v,例如:*ngIf="tileNameInput.errors.required"