https://stackoverflow.com/questions/32693061/how-can-i-select-an-element-in-a-component-template/35209681#35209681
@viewChild without read parameters means to access the component or HTML in template thats already rendered
<input #myname>
@ViewChild('myname') input;
element
ngAfterViewInit() {
console.log(this.input.nativeElement.value);
}
@viewChild with read parameters means to dynamically create component on a already rendered page
@ViewChild('myname', { read: ViewContainerRef }) target;
target.createComponent( this.resolver.resolveComponentFactory( Yourcomponent ) );
No comments:
Post a Comment