How to use Jquery in Angular 2

Asked

Viewed 1,426 times

1

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

I intend to implement the theme in an Angular 2 project, in certain pages there are animations, manipulations of the DOM 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 information there.

How do I get my information to Jquery from a method/variable of my Angular component?

Ex:

onViewChecked(){
$(".classe-escolhida").click(function(){
alert("Cliclado");
});
}
  • Can’t do everything in Angular?

  • @Andersoncarloswoss I’ve already edited for better understanding

1 answer

0

Utilize declare var $: any; before the declaration of the Class.

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");
    });
  }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.