1

テンプレート駆動のAngularフォームに取り組んでいます。ユーザーが [さらに追加] ボタンをクリックしたときに検証エラー メッセージを表示したい。

以下は私のフォームです。

    <form #billingLocationForm='ngForm' role="form" (ngSubmit)="formSubmit(billingLocationForm.value)" novalidate id="add_billing_contact_form" name="addBillingForm">
        <div class="col-lg-4 col-xs-6"> 
              <label for="bill_location_1">Billing location</label>
              <input type="text" id="bill_location_1" #billLocation1Ref="ngModel" [(ngModel)]="billLocation1_txt" name="billLocation1" required />

              <div *ngIf="billLocation1Ref.errors && (billLocation1Ref.dirty || billLocation1Ref.touched) " class="form_err_msg">
                   <div [hidden] ="!billLocation1Ref.errors.required">
                   Please enter your Billing location
                   </div>
              </div>               
        </div>          
    <button class="btn btn-block btn-full" type="submit" [disabled]="!billingLocationForm.form.valid">Submit</button>

</form>

<a href="javascript:void(0)" (click)="addMoreField()">
   <span class="glyphicon glyphicon-plus">Add More</span>
</a>   

望ましい結果を達成する方法を親切に提案してください。

ありがとうございました

4

0 に答える 0