使用example,仅更改名称,将多个选择的SelectionModel构造函数第一个参数设置为true。第二个参数是初始选择的值的数组。数组显示在SelectionModel中
SelectionModel changed:
Subject {_isScalar: false, observers: Array(1), closed: false, isStopped: false, hasError: false, …}
onChange: Subject {_isScalar: false, observers: Array(1), closed: false, isStopped: false, hasError: false, …}
selected: (...)
_deselectedToEmit: []
_emitChanges: true
_multiple: true
_selectedToEmit: []
_selection: Set(1)
size: (...)
__proto__: Set
[[Entries]]: Array(1)
0: MonthlyBudgetFlatNode
value: MonthlyBudgetFlatNode {expandable: false, level: 1, name: "2012-08-01"}
length: 1
,但从未选中该复选框。如果我检查树项之一,则会将其添加到数组中。我什至可以检查初始数组中列出的同一个并将其添加。我已经将package.json更新为最新的内容,没有任何更改。
"@angular/animations": "^7.2.9",
"@angular/cdk": "^7.3.4",
"@angular/common": "^7.2.9",
"@angular/compiler": "^7.2.9",
"@angular/core": "^7.2.9",
"@angular/forms": "^7.2.9",
"@angular/http": "^7.2.9",
"@angular/material": "^7.3.4",
"@angular-devkit/build-angular": "^0.12.4",
"@angular/cli": "^7.3.6",
"@angular/compiler-cli": "^7.2.9",
这里是构造函数:
this.checklistSelection = new SelectionModel<MonthlyBudgetFlatNode>(
true, this.selectedMonthlyBudgetFlatNode, true
);
this.onChecklistChanged(this.checklistSelection.changed);
谢谢