0

Here is my code in Angular

index.html

<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>

<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>

<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />

Code in .ts file:

declare var jQuery: any;
@ViewChild('reportrange') reportrange: ElementRef;

ngAfterViewInit()
{
  jQuery(this.reportrange.nativeElement).daterangepicker();
}

I keep getting jQuery(...).daterangepicker is not a function error when I compile.

What's the right approach to solve this?

Anirudh
  • 2,767
  • 5
  • 69
  • 119

1 Answers1

0

It is pretty simple and will require you to install a package, you can find instructions below:

How to use jQuery with Angular

Mac_W
  • 2,927
  • 6
  • 17
  • 30