I have a small helper class that needs to do a little DOM manipulation. I was trying to use ViewChild() following this and a few others but it can't compile. I am guessing ViewChild() requires @Component directive to work?
My current class is:
@Injectable()
export class calculator {
constructor(){}
calculate(calling_btn:string){
//while a rather longish calcualtion is done, I need to disable the specific btn that called the calculate method. then display the result.
@ViewChild(calling_btn) ele: ElementRef;
}
html:
<button #stage1 (click)="calculate('stage1')">Stage 1</button>
There can be maximum 15 buttons that will request calculation and I want to disable each button that requests calculation then return result. It is working but sometimes users click one button multiple times and I wanted to stop that.
It works well if I use getElementById but i read it is not good practice. Any idea?