是否可以使用模板驱动形式的布尔值数组绑定到多个复选框?

Is it possible to bind to multiple checkboxes with an array of boolean values in a template driven form?

我都知道FormArray from reactive forms and the method of objects in an array or map as described in 。通常我会使用前者,如果绝对必要则使用后者 - 但我想知道是否可以使用 just 一个 boolean 值的数组。

模板

<div>
  <h2>Hello {{name}}</h2>
</div>
<input type="checkbox" *ngFor="let item of items; let i = index;" [(ngModel)]="items[i]"/>

分量

@Component({
  selector: 'my-app',
  template: `...`,
})
export class App {
  name:string;
  items = [false, false, true];
  constructor() {
    this.name = `Angular! v${VERSION.full}`
  }
}

对于上述文件,单击第一个复选框将更改其他复选框的值。是我弄错了吗,或者这在 Angular 中是不可能的?

显示错误行为的 Gif:

Live example on Plunker

ngFor 必须升级才能避免引用问题。

<div *ngFor="let item of items; let i = index;" >
     <input type="checkbox" [(ngModel)]="items[i]"/>
</div>

Updated Plunker