【问题标题】:How to create drag attribute directive in angular 2.0?如何在 Angular 2.0 中创建拖动属性指令?
【发布时间】:2023-04-01 17:34:01
【问题描述】:

我关注angular docs 为拖动创建属性指令,但ondrag 事件不起作用。另一端mouseentermouseleave 工作正常(在文档中提到)。有什么建议吗?

import {Directive, ElementRef, Input} from 'angular2/core';
@Directive({
    selector: '[myHighlight]',
    host: {
        '(ondrag)' : 'onDrag()'
    }
})
export class HighlightDirective {
      //constructor(private el: ElementRef) { }
    onDrag(){
        console.log("onDrag...");
    }
}

【问题讨论】:

标签: javascript angular angular2-directives


【解决方案1】:

没有ondrag 事件。您要查找的事件只是drag

【讨论】:

  • 知道了。愚蠢的我。
【解决方案2】:

我只是想用更精确的方式扩展答案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多