jmcooper / angular-fundamentals-files

353 stars 536 forks source link

ERROR TypeError: _this.$ is not a function #8

Open shaheenaakhter opened 5 years ago

shaheenaakhter commented 5 years ago

Hi there,

I'm creating ModalTriggerDirective ,have followed each and every bit of the course.When trying to open dialog box on click of search button.I get this error.Please help :(.

ModalTriggerDirective

Have created JQ_TOKEN and imported the service in the directive. app.module.ts let jQuery: any; {provide: JQ_TOKEN, useValue: jQuery}

qxl0 commented 4 years ago

I got into the exact error. It's not easy to fix.

ArinzeOkorji commented 4 years ago

I am facing the same issue.

ArinzeOkorji commented 4 years ago

In the directive file, add

import $ from 'jquery' ; declare var $:$;

Remove/comment out the token injection in the constructor

use $ instead of this.$ in the addEventListener function.

Worked for me.