我正在一个项目中,该项目包含一个用于保存更改的按钮。我只想单击按钮后3秒后显示示例消息。像下面的例子一样
<div>
<button *ngIf="show" class="fade in" role="">Save</button>
<p SOW THIS MESSAGE 3s AFTER CLICK SAVE> <strong>just Saved!</strong> Your changes has been saved.<p>
答案 0 :(得分:0)
.html:
<button (click)="showMessageSoon()">Show Message</button>
<p *ngIf="showMyMessage">hello there</p>
.ts:
public showMyMessage = false
showMessageSoon() {
setTimeout(() => {
this.showMyMessage = true
}, 3000)
}