admin管理员组文章数量:1429857
I'm working in a project that includes a button to save a change. I just wanted a sample message shown after 3s after the button is clicked. smt like the below example
<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>
I'm working in a project that includes a button to save a change. I just wanted a sample message shown after 3s after the button is clicked. smt like the below example
<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>
Share
Improve this question
edited Sep 25, 2018 at 20:52
danday74
57.5k55 gold badges269 silver badges333 bronze badges
asked Sep 25, 2018 at 19:03
Hicham MARKUSHicham MARKUS
491 gold badge3 silver badges7 bronze badges
1
- When you click the save button, create a timer, and pass a call back to set the show variable after 3 seconds – johnny 5 Commented Sep 25, 2018 at 20:36
1 Answer
Reset to default 2.html:
<button (click)="showMessageSoon()">Show Message</button>
<p *ngIf="showMyMessage">hello there</p>
.ts:
public showMyMessage = false
showMessageSoon() {
setTimeout(() => {
this.showMyMessage = true
}, 3000)
}
本文标签: javascriptAngular 6 How to show Message after button is clickedStack Overflow
版权声明:本文标题:javascript - Angular 6 How to show Message after button is clicked - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745504783a2661195.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论