我正在尝试在 PrimeNG 树中设置选定的项目。
HTML
<p-tree id="selectedProducts" *ngIf="selectedCustomer != null"
[value]="tree" selectionMode="checkbox"
[(selection)]="selectedProducts"
(click)="fileterProducts()"></p-tree>
TS
selectedProducts: TreeNode[] = [];
filteredProducts: number[] = [];
tree: TreeNode[] = [];
selectCustomer(customerId: number){
this.selectedCustomer = this.selectedCustomers.find(r => r.Name == this.userForm.value.Customers[0]);
console.log("Customer Products ");
console.log(this.selectedCustomer.selectedProducts);
this.selectedProducts = this.selectedCustomer.selectedProducts;
for ( let product of this.selectedProducts ) {
product.expanded = true;
this.expandChildren(product);
console.log('Product : ');
console.log(product);
}
我让所有节点都展开了,但它似乎没有被选中。