Dom Manipulate in angular
Faisal Ahmed
Posted on July 8, 2024
<h2 #hello1>Hello world</h2>
<button (click)="handleFunction()">Change Text</button>
@ViewChild('hello1', { static: true }) helloElement: ElementRef;
handleFunction() {
this.helloElement.nativeElement.textContent = 'Hello Angular!';
this.helloElement.nativeElement.style.color = 'red';
this.helloElement.nativeElement.style.backgroundColor = 'yellow';
this.helloElement.nativeElement.style.fontSize = '30px';
}
💖 💪 🙅 🚩
Faisal Ahmed
Posted on July 8, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.