0

I have a library which has a function structure like this..

$.fn.et_menu = function ( options ) {
var settings = $.extend({
type: "default", // can be columns, default, mega, combined
animTime: 250,
openByClick: true,
delayTime: 0
}, options );

which should be called like

$('.menu.side-menu').et_menu({
type: "default",
delayTime: 0
});

Any help.. how to integrate this in Angular..

Ive included the library in my index.html file and did

declare var et_menu: any;

in my component.ts file..

Any help would be rally greatful.

4
  • did you add the javascript file to src/assets Commented Jul 28, 2017 at 7:54
  • You have included the library on your index.html file... and? What happened? How should runtime know that et_menu is some property of object fn of object $? Have you tried window["$"].fn.et_menu? Commented Jul 28, 2017 at 7:56
  • 1
    Which version of Angular? Commented Jul 28, 2017 at 8:02
  • Its angular 2, Ive made jquery workable, but cannot figure how to call function $('.menu.side-menu').et_menu({ type: "default", delayTime: 0 }); Its saying Property 'et_menu' does not exist on type 'JQuery<HTMLElement>'. Commented Jul 28, 2017 at 8:49

1 Answer 1

2

Step One

npm install jssha --save [using jssha for this demo]

It it is your own custom file place it in the scripts array of angular-cli.json skip this step 1

Step two

Add the jssha scripts file in .angular-cli.json file
"scripts": [ "../node_modules/jssha/src/sha.js" ]

Step three Adding a var in component to be used as a global variable

//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")

Take a look @ this link. It has a working example and a question for the same with typings and without it.

Sign up to request clarification or add additional context in comments.

8 Comments

thank you but I've looked into it very carefully... thats a bit different i guess..
What is different please tell may be i can help
I guesa you need to add two variables one for jquery and other for et then it will work
$('.menu.side-menu').et_menu({ type: "default", delayTime: 0 });
In case of normal page we do something like.. $('.menu.side-menu').et_menu({ type: "default", delayTime: 0 });
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.