What's the proper way for loading jQuery functions in Angular 2?
I've added my jQuery to ngAfterViewInit
. It works fine for one route, but if I navigate to another one (e.g. from id: 1
to id: 2
), it doesn't work for the second one (I'm using the same component for both).
It works using ngAfterViewChecked
but, then, the function is executed multiple times (after every change in the view).
This is my jQuery function:
$('.chips').on('chip.add', (e, chip) => {
console.log(e, chip);
});