stackoverflow.com/questions/42057886/...
ular2 мне нужно дублировать узел, а не перемещать его в некоторых случаях. Этот узел имеет свойства angular2, поэтому cloneNode не работает. Как мне это сделать?
* что не работает
let el = <HTMLElement>document.getElementById(divId);
if ((<HTMLElement>el.parentNode).id == 'itsMe')
el = <HTMLElement>el.cloneNode(true);
document.getElementById(anotherId).appendChild(el);
* что будет работать, отAngular2: компонент клонирования / элемент HTML и его функциональность
@Component({
selector: 'my-app',
template: `
<template #temp>
<h1 [ngStyle]="{background: 'green'}">Test</h1>
<p *ngIf="bla">Im not visible</p>
</template>
<template [ngTemplateOutlet]="temp"></template>
<template [ngTemplateOutlet]="temp"></template>
`
})
export class AppComponent {
bla: boolean = false;
@ContentChild('temp') testEl: any;
}
Но как добавить шаблон динамически?