美文网首页
angular中实现一次点击

angular中实现一次点击

作者: 猛同学 | 来源:发表于2019-12-20 21:31 被阅读0次

    1 变量控制

    import {Component, AfterViewInit, Renderer, ViewChild, ElementRef} from '@angular/core';@Component({ template: `<button #button>...</button>`})

    export class SampleComponent implements AfterViewInit { @ViewChild('button') button: ElementRef; private cancelClick: Function; 

    constructor(private renderer: Renderer) {} 

     ngAfterViewInit() { this.cancelClick = this.renderer.listen(this.button.nativeElement, 'click', ($event: any) => this.handleClick($event)); } 

     handleClick($event: any) { this.cancelClick(); // ... }}

    3

    第三方 event 实现

    <button (once.click)="handleClick($event)">...</button>

    angularEvent

    相关文章

      网友评论

          本文标题:angular中实现一次点击

          本文链接:https://www.haomeiwen.com/subject/hwybnctx.html