Angular Prime NG:typescript中的树传播SelectionUp

Angular Prime NG:typescript中的树传播SelectionUp,angular,typescript,tree,primeng,Angular,Typescript,Tree,Primeng,我是一个使用JHipster构建的应用程序的初学者,使用Angular 4.3和Priming。 我有一棵树和一个搜索栏 当我点击打开树时,复选框很好,如下所示: 但我有一个问题,当我在搜索栏中进行研究时,我用typescript代码手动打开树,当我将右叶放入所选节点时,它不会检查国家和大陆(父节点): 这是我的HTML代码: <jhi-search-bar [data]="items" (onItemSelected)="openNodeAfterSearch($event)

我是一个使用JHipster构建的应用程序的初学者,使用Angular 4.3和Priming。 我有一棵树和一个搜索栏

当我点击打开树时,复选框很好,如下所示:

但我有一个问题,当我在搜索栏中进行研究时,我用typescript代码手动打开树,当我将右叶放入所选节点时,它不会检查国家和大陆(父节点):

这是我的HTML代码:

    <jhi-search-bar [data]="items" (onItemSelected)="openNodeAfterSearch($event)"></jhi-search-bar>
    <p-tree class="arbre"
                        [loading]="loading"
                        [value]="nodes"
                        selectionMode="checkbox"
                        (onNodeSelect)="onChange()"
                        (onNodeUnselect)="onChange()"
                        [(selection)]="selectedNodes"></p-tree>
openNodeAfterSearch(item: any) {
    const racine = this.nodes[0];
    // I close all unecessary opened nodes
    for (const continent of racine.children) {
        continent.expanded = false;
        for (const country of continent.children) {
            country.expanded = false;
            for (const item of country.children) {
                if (item.data.id === item.item.id) { // right node to open

                    this.selectedNodes = [];
                    this.selectedNodes.push(item);

                    country.expanded = true; // open parent's node
                    continent.expanded = true;
                }
            }
        }
    }
}
我已尝试此HTML属性,但失败:

[propagateSelectionUp]="true" 
我也不想这样继续下去:

this.selectedNodes.push(country);
this.selectedNodes.push(continent);
因为我得到了这个:

有人有主意吗


朱莉。

我找到了解决办法:

country.partialSelected = true;
continent.partialSelected = true;

只需要添加一些条件来检查是否选中了所有子项

已解决:)

您应该在此属性中使用括号

[propagateSelectionUp]=“false” [propagateSelectionDown]=“false”