-1

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?

Yashasvi
  • 197
  • 1
  • 3
  • 6

1 Answers1

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();
    }
}
  1. declare var $:any; --> declare jquery
  2. $('#side-menu').metisMenu(); --> jquery code
Taras Kovalenko
  • 2,323
  • 3
  • 24
  • 49