Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
导出jquery插件,并在Angular中作为模块导入,然后在指令中使用它?_Jquery_Angular_Plugins - Fatal编程技术网

导出jquery插件,并在Angular中作为模块导入,然后在指令中使用它?

导出jquery插件,并在Angular中作为模块导入,然后在指令中使用它?,jquery,angular,plugins,Jquery,Angular,Plugins,我决定为angular 7创建一个插件。作为示例代码: (function ( $ ) { $.fn.greenify = function( options ) { // This is the easiest way to have default options. var settings = $.extend({ // These are the defaults. color: "#556b2f

我决定为angular 7创建一个插件。作为示例代码:

(function ( $ ) {

    $.fn.greenify = function( options ) {

        // This is the easiest way to have default options.
        var settings = $.extend({
            // These are the defaults.
            color: "#556b2f",
            backgroundColor: "white"
        }, options );

        // Greenify the collection based on the settings variable.
        return this.css({
            color: settings.color,
            backgroundColor: settings.backgroundColor
        });

    };

}( jQuery ));

$( "div" ).greenify({
    color: "brown"
});
例如在上面的代码中, 1.如何在angular as模块中导入此项? 2.如何在angular中使用它作为指令(如何在angular模板中使用它作为指令?)

我在找指导。提前谢谢

希望像这样使用:

从'MyPlugin'导入{MyPlugin}

在模板中:
-类似这样的东西。

不要在Angular应用程序中使用jQuery。Angular指令可以访问本机DOM元素,您可以使用TypeScript进行css更改,而无需使用jQuery。这似乎是一种相当复杂的方法,通常只需使用css类即可完成。我同意,我的问题与此不同。我需要使用具有多个团队的多个项目的单个库。我发现jquery插件比向多个团队解释所有事情要好得多