久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <small id='P3F9z'></small><noframes id='P3F9z'>

    <legend id='P3F9z'><style id='P3F9z'><dir id='P3F9z'><q id='P3F9z'></q></dir></style></legend>

        <bdo id='P3F9z'></bdo><ul id='P3F9z'></ul>
      <tfoot id='P3F9z'></tfoot>

    1. <i id='P3F9z'><tr id='P3F9z'><dt id='P3F9z'><q id='P3F9z'><span id='P3F9z'><b id='P3F9z'><form id='P3F9z'><ins id='P3F9z'></ins><ul id='P3F9z'></ul><sub id='P3F9z'></sub></form><legend id='P3F9z'></legend><bdo id='P3F9z'><pre id='P3F9z'><center id='P3F9z'></center></pre></bdo></b><th id='P3F9z'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='P3F9z'><tfoot id='P3F9z'></tfoot><dl id='P3F9z'><fieldset id='P3F9z'></fieldset></dl></div>

        Angular2指令修改點(diǎn)擊處理

        Angular2 Directive to modify click handling(Angular2指令修改點(diǎn)擊處理)
        <i id='mK1sj'><tr id='mK1sj'><dt id='mK1sj'><q id='mK1sj'><span id='mK1sj'><b id='mK1sj'><form id='mK1sj'><ins id='mK1sj'></ins><ul id='mK1sj'></ul><sub id='mK1sj'></sub></form><legend id='mK1sj'></legend><bdo id='mK1sj'><pre id='mK1sj'><center id='mK1sj'></center></pre></bdo></b><th id='mK1sj'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='mK1sj'><tfoot id='mK1sj'></tfoot><dl id='mK1sj'><fieldset id='mK1sj'></fieldset></dl></div>
            • <bdo id='mK1sj'></bdo><ul id='mK1sj'></ul>
                    <tbody id='mK1sj'></tbody>

                  <legend id='mK1sj'><style id='mK1sj'><dir id='mK1sj'><q id='mK1sj'></q></dir></style></legend>
                1. <small id='mK1sj'></small><noframes id='mK1sj'>

                  <tfoot id='mK1sj'></tfoot>
                2. 本文介紹了Angular2指令修改點(diǎn)擊處理的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我正在嘗試編寫一個(gè) Angular2 屬性指令來修改某些元素的行為.更具體地說,我想將屬性應(yīng)用于具有點(diǎn)擊處理程序的某些元素,并防止綁定函數(shù)在某些條件下執(zhí)行.

                  I am trying to write a Angular2 attribute directive to modify the behaviour of certain elements. More specifically I want to apply an attribute to certain elements that have click handlers and prevent the bound function to be executed under certain conditions.

                  所以現(xiàn)在我有一個(gè)元素,例如:

                  So now I have an element e.g.:

                  <button (click)="onClick(param1, param2)"></button>
                  

                  onClick 是在承載按鈕元素的組件上聲明的函數(shù).

                  onClick is a function declared on the component that hosts the button element doing some work.

                  我想做的是這樣寫:

                  <button (click)="onClick(param1, param2)" online-only></button>
                  

                  并有一個(gè)類似的指令:

                  @Directive({
                    selector: '[online-only]',
                  })
                  export class OnlineOnlyDirective {
                    @HostListener('click', ['$event']) 
                    onClick(e) {
                      if(someCondition){
                        e.preventDefault();
                        e.stopPropagation();
                      }
                    }
                  }
                  

                  但是單擊處理程序首先執(zhí)行,因此我的指令沒有機(jī)會停止執(zhí)行.

                  But click handler is executed first, thus not giving my directive the opportunity to stop its execution.

                  我想到的第二種方法是用我自己的處理程序替換(單擊),例如([onlineClick]="onClick")并在指令認(rèn)為合適時(shí)執(zhí)行傳遞的函數(shù),但是這樣我不能將參數(shù)傳遞給 onClick 函數(shù)和看起來有點(diǎn)奇怪.

                  A second approach I thought about was replacing (click) with my own handler e.g.( [onlineClick]="onClick" ) and execute the passed function when the directive thinks fit, but this way I cannot pass params to onClick function and is a bit weirder to look at.

                  你對做這樣的事情有什么想法嗎?

                  Do you have any thoughts on doing something like that?

                  推薦答案

                  我不知道有什么方法可以強(qiáng)制 Angular 先執(zhí)行某個(gè)事件處理程序.一種解決方法可能是使用自定義事件,例如:

                  I don't know of a way to force Angular to execute a certain event handler first. A workaround might be to use a custom event like:

                  <button (myClick)="onClick(param1, param2)" online-only></button>
                  

                  @Directive({
                    selector: '[myClick]',
                  })
                  export class OnlineOnlyDirective {
                    @Output() myClick: EventEmitter = new EventEmitter();
                    @HostListener('click', ['$event']) 
                    onClick(e) {
                      if(someCondition){
                        e.preventDefault();
                        e.stopPropagation();
                      } else {
                        this.myClick.next(e);
                      }
                    }
                  }
                  

                  這篇關(guān)于Angular2指令修改點(diǎn)擊處理的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項(xiàng)目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數(shù)據(jù)更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創(chuàng)建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態(tài)元素 - Angular 2 amp;離子2)

                    <tfoot id='XBPo9'></tfoot>

                    <legend id='XBPo9'><style id='XBPo9'><dir id='XBPo9'><q id='XBPo9'></q></dir></style></legend>
                  1. <small id='XBPo9'></small><noframes id='XBPo9'>

                      <tbody id='XBPo9'></tbody>
                    <i id='XBPo9'><tr id='XBPo9'><dt id='XBPo9'><q id='XBPo9'><span id='XBPo9'><b id='XBPo9'><form id='XBPo9'><ins id='XBPo9'></ins><ul id='XBPo9'></ul><sub id='XBPo9'></sub></form><legend id='XBPo9'></legend><bdo id='XBPo9'><pre id='XBPo9'><center id='XBPo9'></center></pre></bdo></b><th id='XBPo9'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XBPo9'><tfoot id='XBPo9'></tfoot><dl id='XBPo9'><fieldset id='XBPo9'></fieldset></dl></div>
                      • <bdo id='XBPo9'></bdo><ul id='XBPo9'></ul>

                            主站蜘蛛池模板: 最新中文字幕在线 | 羞羞视频网站在线观看 | 澳门永久av免费网站 | 91视频18| 黄色在线观看国产 | 国产高清美女一级a毛片久久w | 亚洲第一成人av | 日韩不卡一区二区三区 | 亚洲精品日韩在线 | 亚洲国产成人精品女人久久久 | 日韩在线欧美 | 久久蜜桃av一区二区天堂 | 欧美精品久久久久 | 国产精品一区二区免费看 | 国产高清视频在线观看 | 欧美日韩亚洲国产 | 成人在线视频免费观看 | 精品视频一区二区 | 国产精品九九九 | 亚洲欧美一区二区在线观看 | 永久精品 | 日韩男人天堂 | 欧美电影免费观看高清 | 欧美在线观看一区二区 | 夜夜夜夜夜夜曰天天天 | 日韩三级一区 | 午夜免费| 美女久久视频 | 天堂久久网 | 亚洲国产区 | 国产精品亚洲第一区在线暖暖韩国 | 超碰在线免费av | 亚洲国产成人精品久久 | 男女羞羞的网站 | 精品久久亚洲 | 亚洲精品欧美 | 国产精品久久久久久中文字 | 欧美在线成人影院 | 久久男人| 欧美日韩中文国产一区发布 | 国产精品中文在线 |