1
[ngModel]でバインドしている間にngForの入力タイプ= "text"から値を取得する際に問題があります。 ngForですべての入力をバインドできますか?入力タイプからの入力値を取得するにはngForの入力タイプ= "text"
HTML
<button (click)="saveFeature()" type="button">save</button>
<input class="form-control" type="text" />
<button (click)="addFeature()" type="button">Add</button>
<div *ngFor="let inputservice of servicesfeature_id; let i=index">
<input class="form-control" [(ngModel)]="listServiceFeature" type="text" />
<button (click)="RemoveFeature(i)" type="button">Remove</button>
</div>
コンポーネント
servicesfeature_id: any = [];
servicesfeature_length: number = 0;
listServiceFeature: any = [];
servicefeature_name: string;
saveFeature(): void {
console.log(this.listServiceFeature);
}
addFeature(): void {
this.servicesfeature_id.push('service' + this.servicesfeature_length);
this.servicesfeature_length += 1;
}
RemoveFeature(index): void {
this.servicesfeature_length -= 1;
this.servicesfeature_id.splice(index, 1);
}
は、ここで私はこのことを理解していれば、あなたが入力がlistServiceFeature
、アレイのメンバーに結合したいコードplnkr.co