Angular 自訂輸入項元件

HI 大家好

想問一下大家在做 form 表單時是否會輸入項(input)包成component

例如:

<form [formGroup]="form">
 <div class="row">
  <div class="col-xs-12">
    <div class="form-group">
      <label for="name">{{labelTitle}}</label>
      <input
    type="text"
    id="name"
    class="form-control"
    [(ngModel)]="answer" (change)="textChange()"
    />
    </div>
  </div>
</div>
</form>

變成

<form [formGroup]="form">
  <app-control-input [labelTitle]='"姓名 : "' formControlName='name'></app-control-input>
</form>
  1. 想問一下大家在做 form 表單時是否會輸入項包成component???

  2. 如過是這樣要如何即時同步輸入的值?? 現在都會輸入後要來輸入項值才會變

我的程式

(change) 改用 (ngModelChange)="textChange($event)" 就可以了

可以了 ,感謝 Kevin 大大