I want to use JavaScript file in angular 2. For Example, I have "multi-select" JavaScript file, which I can used simply doing $(".select2_demo_1").select2();
in html page. But i want to use this JavaScript file in angular 2. Is there any way to use this JavaScript or need to use it's angular 2 version?
Asked
Active
Viewed 414 times
-1

Yashasvi
- 197
- 1
- 3
- 6
-
2http://stackoverflow.com/search?q=%5Bangular2%5D+javascript+library – Günter Zöchbauer Jan 20 '17 at 08:10
-
Possible duplicate of [Angular2: import external js file into component](http://stackoverflow.com/questions/37081943/angular2-import-external-js-file-into-component) – disappointed in SO leadership Jan 20 '17 at 18:35
1 Answers
0
Angular 2 supported JS code.
Example:
import { Component } from '@angular/core';
import {Router} from '@angular/router';
declare var $:any;
@Component({
selector: 'navigation',
templateUrl: 'navigation.template.html'
})
export class NavigationComponent {
constructor(private router: Router) {}
ngAfterViewInit() {
$('#side-menu').metisMenu();
}
}
declare var $:any;
--> declare jquery$('#side-menu').metisMenu();
--> jquery code

Taras Kovalenko
- 2,323
- 3
- 24
- 49