How to use JQuery in Angular 2

1

I have a theme in HTML, CSS, JAVASCRIPT and Frameworks like Bootstrap, JQuery, etc. have been used.

I intend to implement the theme in an Angular project 2, on certain pages there are animations, DOM manipulations that are made by the manufacturer of the theme that I would like to have on the site as they are in the theme, but with some manipulation of existing information.

How do I provide my information to JQuery from a method / variable of my Angle component?

Ex:

onViewChecked(){
$(".classe-escolhida").click(function(){
alert("Cliclado");
});
}
    
asked by anonymous 19.10.2017 / 11:51

1 answer

0

Use declare var $: any; before class declaration.

Example:

import { Component } from '@angular/core';

declare var $: any;

@Component({
  selector: 'app-modulo',
  templateUrl: './modulo.component.html',
  styleUrls: ['./modulo.component.scss']
})
export class ModuloComponent
{
  constructor(){}

  onViewChecked(){
    $(".classe-escolhida").click(function(){
      alert("Clicado");
    });
  }
}
    
12.12.2017 / 23:05