1

after新しい子ノードを親ノードに追加したいのですが、appendChildそれを追加しinsideます。ここに私が持っているものがあります:

私のcomponent.html

<div id="parent" (click)="appendChild()">
    parent node
</div>

私のcomponent.ts

private appendChild() {
    const div = this.renderer.createElement('div');
    const text = this.renderer.createText('child node')
    this.renderer.appendChild(div, text);
    this.renderer.appendChild(document.getElementById("parent"), div)
}

これは、次のようにノードdiv内で作成されたnew を挿入します。parent

ここに画像の説明を入力

parentしかし、ノードの外に追加するにはどうすればよいですか? このような:ここに画像の説明を入力

4

1 に答える 1