什么对象类型是实例元素参数传递到角度指令的链接函数?

Mic*_*lle 10 d3.js angularjs typescript

我正在使用带有角度的typescript并尝试创建自定义指令.我试图给出我所有的参数类型,但不确定传递$ element参数的对象是什么类型.是JQuery类型吗?还是一些元素类型?

在指令代码中,我想使用带有d3选择器的$元素.(即d3.select($ element))目前d3选择语句不起作用,因为$元素类型不是d3所期望的类型.(我也在使用d3的打字稿界面.)

var directiveDefinitionObject : ng.IDirective = {
        restrict: 'E',
        replace: false,
        scope: { data: '=chartData' },
        link: ($scope: ICustomScope, $element: <WHAT_TYPE?>) => {
             d3.select($element);  // d3.select(node)
        }
    };
Run Code Online (Sandbox Code Playgroud)

Sco*_*ott 9

$elementlink指令的功能有类型ng.IAugmentedJQuery.如果你包含jQuery然后你将获得jQuery函数$element,没有jQuery然后Angular将提供jqLit​​e.有关更多信息,请参见此处

link函数ng.IDirective被定义为:

link?: (scope: IScope,
        instanceElement: IAugmentedJQuery,
        instanceAttributes: IAttributes,
        controller: any,
        transclude: ITranscludeFunction
       ) => void;
Run Code Online (Sandbox Code Playgroud)