2017-07-15 13 views
1

を保存する時にangular2ソースコードにHTML5の要素をバインドする方法このデータはAngular2ソースコード側で結合されていない理由私は、ユーザーアクセス用の一部のHTMLコードを実装するが、Angular2を使用しています。ここモード

Htmlcode

<form class="form-horizontal" novalidate [formGroup]="EmployeeForm"> 
    <fieldset> 
     <div class="form-group" [ngClass]="{'has-error': (EmployeeForm.get('EmpName').touched || 
                EmployeeForm.get('EmpName').dirty) && 
                !EmployeeForm.get('EmpName').valid }"> 
      <label for="name">Name</label> 
      <input type="text" class="form-control" formControlName="EmpName" [(ngModel)]="EmpName" /> 
      <span>{{EmpName}}</span> 
      <span class="help-block" *ngIf="(EmployeeForm.get('EmpName').touched || 
                 EmployeeForm.get('EmpName').dirty) && 
                 EmployeeForm.get('EmpName').errors"> 
       <span *ngIf="EmployeeForm.get('EmpName').errors.required"> 
        Please enter your first name. 
       </span> 
       <span *ngIf="EmployeeForm.get('EmpName').errors.minlength || EmployeeForm.get('EmpName').errors.maxlength || 
         EmployeeForm.get('EmpName').pattern"> 
        The first name must be longer than A3 and max5 characters. 
       </span> 
      </span> 
     </div> 
<button type="submit" class="btn btn-success" [disabled]="!EmployeeForm.valid" (click)="SaveDetails(EmployeeForm)">SaveDetails</button> 
    </fieldset> 
</form> 

component.tsここ そのピングが、データが

zain = FormGroup {asyncValidator: null, _pristine: false, _touched: true, validator: function, _onCollectionChange: function…} 



SaveDetails(Employee) { 

    } 
としての上映を結合されていません210

答えて

0

<button type="submit" class="btn btn-success" [disabled]="!EmployeeForm.valid" (click)="SaveDetails(EmployeeForm.value)">SaveDetails</button> 

<button type="submit" class="btn btn-success" [disabled]="!EmployeeForm.valid" (click)="SaveDetails(EmployeeForm)">SaveDetails</button> 

からコードを変更してみてください

関連する問題