Dom Manipulate in angular

webfaisalbd

Faisal Ahmed

Posted on July 8, 2024

Dom Manipulate in angular
<h2 #hello1>Hello world</h2>
<button (click)="handleFunction()">Change Text</button>
Enter fullscreen mode Exit fullscreen mode
  @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';
  }
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
webfaisalbd
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.

Related