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)
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745504783a4630579.html
评论列表(0条)