Javascript 如何在使用ngModel(angular 11)的选定图元上设置禁用的默认选项

Javascript 如何在使用ngModel(angular 11)的选定图元上设置禁用的默认选项,javascript,angular,typescript,Javascript,Angular,Typescript,我有一个select元素,看起来像这样: <select (change)="handleEvent($event)"> <option [value]="null" selected disabled>Select thing</option> <ng-container *ngIf="data"> <ng-container *ngFor="

我有一个select元素,看起来像这样:

 <select (change)="handleEvent($event)">
    <option [value]="null" selected disabled>Select thing</option>
    <ng-container *ngIf="data">
      <ng-container *ngFor="let item of data">
        <option [value]="item.id">{{ item.name }}</option>
      </ng-container>
    </ng-container>
  </select>
是组件初始化的时间,在本例中该组件未定义。但是,

this.selectedItem = {
  name: "Select a thing"
}
也没有填充该字段。我在init和构造函数中都试过了。有谁知道:

1:为什么默认选项没有填充

2:如何在仍然使用ngModel时禁用默认选项,将selectedItem定义为null,因为该选项的值为null

selectedItem = null;

请尝试(更改)=“handleItemSelected($event)”,而不是(ngModel)。在函数中,您可以将值签名到selectedItem。那么ngValue将在事件上的什么位置?它与目标值不同@您可以在函数中尝试console.log($event)来查看它的内容。最有可能的是,您可以在
$event.target.value
中找到ngValue。我已经这样做了,但我没有看到它。ngValue是一个角度绑定,而不是本机js thinkg,因此我不希望它出现在event.target上。如果你以前在那里看过的话我很想知道在哪里
this.selectedItem = {
  name: "Select a thing"
}
selectedItem = null;