0

I am trying to validate input

    <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>

and I got error:

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)

Can somebody helps me?

John Doe
  • 3,794
  • 9
  • 40
  • 72

1 Answers1

0

Use the name of input field instead of v, like: *ngIf="tileNameInput.errors.required"

skm
  • 1,192
  • 1
  • 11
  • 23