ただ、あなたのクリックイベントの一例を与える
import { TreeNode, TreeModel, TREE_ACTIONS, KEYS, IActionMapping, ITreeOptions } from 'angular-tree-component';
const actionMapping:IActionMapping = {
mouse: {
click: (tree, node, $event) => {
$event.shiftKey
? TREE_ACTIONS.TOGGLE_SELECTED_MULTI(tree, node, $event)
: TREE_ACTIONS.TOGGLE_SELECTED(tree, node, $event)
}
}
};
@Component({
selector: 'category',
template: ` <div class="d-inline-block">
<tree-root #tree [nodes]="categories">
<ng-template #treeNodeTemplate let-node let-index="index">
<span>{{ node.data.name }}</span>
<button (click)="addNode(tree)">add</button>
</ng-template>
</tree-root>
</div>`,
styles : [styles]
})
export class Category implements OnInit {
public categories :any;
addNode(tree) {
this.categories[0].children.push({
name: 'a new child'
});
tree.treeModel.update();
}
。 [これを見る](https://angular2-tree.readme.io/docs/options#actionmapping)これの詳細な例は、 – jgranstrom