javascript - Angular 6 How to show Message after button is clicked - Stack Overflow

I'm working in a project that includes a button to save a change. I just wanted a sample message s

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
Add a ment  | 

1 Answer 1

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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信