我確認表並希望添加ng2-select
它Angular2 - 打字稿:添加一個數組來使用角2 FormControl
這是我的代碼,角& HTML
submit.component.ts
. . .
private city = new FormControl("", Validators.required);
. . .
ngOnInit() {
this.getMelks();
this.addPropertyForm = this.formBuilder.group({
. . .
city: this.city,
. . .
});
}
submit.component.html
<div class="form-group">
<input class="form-control" type="text" name="city" [(ngModel)]="melk.city" placeholder="city" min="0" required>
</div>
我想要的代碼添加:
Angular
:
public city:Array<string> = ['NY','CA' ,'LA'];
HTML
:
<label>City</label>
<ng-select [allowClear]="false"
[items]="city"
[disabled]="disabled"
(data)="refreshValue($event)"
(selected)="selected($event)"
(removed)="removed($event)"
(typed)="typed($event)"
placeholder="Choose the city">
</ng-select>
現在,我怎麼添加NG2選我input
和在FormControl?
你想做什麼?目前還不清楚你想如何添加選擇到輸入... – smnbbrv