问题描述
如何在Nativescript + Angular中获取对组件上指令实例的引用?
我有一个DraggableDirective
,需要拖动组件,但如果它们本身也有DraggableDirective
,则不应该(递归)拖动父容器。
<GridLayout id='outer' appDraggable> <!-- Should only be dragged unless child is dragged as well -->
<GridLayout id='inner' appDraggable></GridLayout> <!-- Should be dragged -->
</GridLayout>
我正在尝试(递归地)获得所有父母,并在孩子拖动打开时禁用该指令。为此,我需要引用属性指令。
import { Directive,ElementRef } from '@angular/core';
@Directive({
selector: '[appDraggable]',exportAs:'draggableDirective'
})
export class DraggableDirective {
constructor(el: ElementRef) {
el.nativeElement.parent.??? // how to get the reference to parent's DraggableDirective? (recursively)
}
...
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)