-1

I need to add a file already created with jquery in my typescript

for example a file that add effect and animations to html (i have already jquery installed)

declare var jQuery:JQueryStatic;

 $("#id").nameOfMyclassOfjQuery({   });

for example I need to integrate a template that create a gridmanager to run this directly in index.html I need to call like this (after I added grid.js into my index.html)

 $(document).ready(function(){
 $("#id").grid({ );
 }); 

but if I'm inside a component.ts how to call this ?? when I put this the word grid is not known by jquery $("#id").grid({ );

khalil _diouri
  • 791
  • 3
  • 12
  • 34

3 Answers3

0

There are bunch of questions and answers here. For example Replace draggable function in angular 2

Same applies to your grid

Community
  • 1
  • 1
Andrei Zhytkevich
  • 8,039
  • 2
  • 31
  • 45
0

I resolve my problem I added just this

interface JQuery {
    gridmanager: any;
}

and I added the gridmanager.js and css files to my project

thanks

khalil _diouri
  • 791
  • 3
  • 12
  • 34
0

If you want to call any jquery code in Angular 2 components call them in ngOnInit method. For instance I was using Materialize CSS with Angular 2 and various components of Materialize required initialisation with jQuery, so this is what I did:-

import { Component, OnInit } from '@angular/core';
declare var jQuery: any;
class SampleClass implements OnInit{
    constructor() { }

    ngOnInit() {
         //Your jQuery code here
    }
}
Kay
  • 142
  • 2
  • 10