ng反映模型未更新选择值-在更新字段页面时

时间:2019-11-18 07:47:47

标签: javascript angular

<select (change)="selectChangeHandler($event)" [ngModel] = "post?.requirement" name="requirement" #requirement="ngModel" class="form-control">
<option value="default">Select category</option>
<option value="add">Add new category</option>
</select>
selectChangeHandler(event: any)

{this.selectedOption = event.target.value;}

1 个答案:

答案 0 :(得分:0)

<select placeholder="Please select" id="myselect" class="form-control" 
              (change)="selectChangeHandler($event)" [ngModel] = "post?.requirement" name="requirement" 
              #requirement="ngModel">
                  <option value="FIT (Customised) Tour Package">FIT (Customised) Tour Package</option></select>

 selectChangeHandler(event: any): void {
    this.selectedOption = event.target.value;
  }