我有一个具有这样的函数结构的库..
$.fn.et_menu = function ( options ) {
var settings = $.extend({
type: "default", // can be columns, default, mega, combined
animTime: 250,
openByClick: true,
delayTime: 0
}, options );
应该这样称呼
$('.menu.side-menu').et_menu({
type: "default",
delayTime: 0
});
任何帮助..如何将其集成到 Angular..
我已将该库包含在我的index.html 文件中并且 做了
declare var et_menu: any;
在我的 component.ts 文件中..
任何帮助都会非常感激。
最佳答案
第一步
npm install jssha --save [using jssha for this demo]
它是您自己的自定义文件,将其放入 angular-cli.json 的脚本数组中,跳过此步骤 1
第二步
Add the jssha scripts file in .angular-cli.json file
"scripts": [ "../node_modules/jssha/src/sha.js" ]
第三步 在组件中添加var作为全局变量
//using external js modules in Angular Component
declare var jsSHA: any; // place this above the component decorator
shaObj:any;
hash:string;
this.shaObj = new jsSHA("SHA-512", "TEXT");
this.shaObj.update("This is a Test");
this.hash = this.shaObj.getHash("HEX")
看看@这个link 。它有一个工作示例和一个与打字和不打字相同的问题。
关于javascript - 如何在 Angular 2 项目中使用 javascript 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45367771/