app.component.ts import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { message: string = "Lorem ipsum dolor sit amet," + "consectetur adipiscing elit. In at ante mattis," + "sollicitudin arcu id, dictum orci." + "Mauris laoreet tincidunt tellus vel faucibus." isDisabled:boolean = false; onClick(){ this.isDisabled = true; setTimeout(()=>{ this.message = "I am changed after 10 seconds on button click." }, 10000); } } app.component.html <h2 style="padding-top:25px; padding-bottom:25px;"> Angular - How to use setTimeout() </h2> <button (click)="onClick()" [disabled]="isDisabled" style="margin-bottom:20px; padding:12px;"> Change Text ...
Web application development tutorials.