suppose i want to insert some HTML element from the server side to the component, how can i do it
import { Component, ElementRef, ViewChild, AfterViewChecked, TemplateRef, ViewContainerRef } from '@angular/core';
@Component({
selector: 'app-root',
template: `
<div>
<h3>this is the container</h3>
<div #holder></div>
</div>
`
})
export class AppComponent implements AfterViewChecked {
@ViewChild('holder', { read: TemplateRef }) _template: TemplateRef<any>;
constructor() { }
ngAfterViewChecked() {
debugger;
this._template.createEmbeddedView('<div>this is a new "div" element</div>');
}
}
in this code i am trying to insert a div to another div with the id='holder' but i am not able to achieve it.
Test
" ); which we do in jQuery, is it not possible with angular4? – Lijin Durairaj Dec 22 '17 at 11:00