angular ref code example
Example 1: set variable inside div angular
// Synchronous:
myVar = { hello: '' };
<ng-container *ngIf="myVar; let var;">
{{var.hello}}
</ng-container>
// Using async pipe:
myVar$ = of({ hello: '' });
<ng-container *ngIf="myVar$ | async; let var;">
{{var.hello}}
</ng-container>
Example 2: angular elementref
// in template
//<div #myEl></div>
@ViewChild("myEl") el: ElementRef;
ngAfterViewInit(){
this.el.nativeElement.innerHTML = "Hi";
console.log(this.el);
}