2016-11-09 103 views
0

嗨,我不konow如何在我的輸入 代碼有效的數字是在這裏Angualr2驗證號碼正則表達式

angular2 Validator Error: Template parse errors:(…)

IM添加此

<form name="authForm" novalidate="" ng-submit="login()" class="md-padding" > 
     <div layout="column" class="layout-column"> 
      <div class="md-form" style="margin-bottom: 64px; margin-top: 20px" [class.invalid]="user.number && user.number.length < 15"> 
       <input class="mdl-textfield__input" [(ngModel)]="user.number" name="number" type="tel" (focus)="focus()" (blur)="focusOut()" [textMask]="{mask: mask}" id="emailInput" required> 
       <label class="mdl-textfield__label" [class.active]="user.number != null" for="emailInput">Numer telefonu</label> 
      </div> 
      <div class="md-form" style="margin-bottom: 44px" [class.invalid]="user.password <= null"> 
       <input class="mdl-textfield__input" [(ngModel)]="user.password" name="password" (focus)="focusPass()" (blur)="focusOutPass()" type="password" id="passInput" required> 
       <label class="mdl-textfield__label" [class.active]="user.password != null" for="emailInput">Hasło</label> 
      </div> 
      <a class="router" routerLink="/panel"><button (click)="logIn($event)" class="md-raised md-accent md-button md-ink-ripple " [class.active]="user.password != null && user.number != null" style="width: 320px" type="submit" aria-label="Zaloguj się"><span>Zaloguj się</span></button></a> 
     </div> 
    </form> 

IM必須做的功能?我有正則表達式的問題,在輸入IM看到「_」字符user.number.length把它看做一個標誌

回答

0

這可能會造成混淆模型的

財產與打字稿號碼類型。您是否嘗試用mobile_number或其他名稱更改號碼?

TypeScript Basic Types

我通常使用的 '數字' 隨這個包。當你想搭建 - 不是

Angular2-Validation