I want to bind an elementref from an object to my html in angular. What I tried is:
<div #[sec_variable] ></div> OR <div #sec_variable ></div>
and get it from @ViewChild() but it says its null.
<div class="nav-item" *ngFor="let input of inputs">
<div #[input.name] /></div>
</div>
AND
@ViewChild('image',{static:true,read:ElementRef}) img?
ngOnInit(): void {
const label = this.renderer.createElement('label');
this.renderer.setAttribute(label, 'for', 'image');
this.renderer.appendChild(this.img.nativeElement, label)
}
BUT it is not working. How can I use it dynamicaly