I'm having problems embedding a jQuery cascading dropdown component to my Angular 6 project. I got an error when attempting to run ng serve
:
Error: ENOENT: no such file or directory, open C:\nodeprojects\node_modules\jquery\dist\jquery.min.js.
Here are the steps I took to add jQuery to Angular 6:
- Ran
npm install jquery
' and verified jquery.min.js
was in that path listed above.
Modified
angular.json
(Angular 6 no longer has an 'angular-cli.json' file) and added the relative path to thejquery.min.js
file in the 'scripts []' section.I'm using
app.component
as the target component. Inapp.component.ts
, I entered,declare var $: any;
and entered the jquery custom component function insideexport class AppComponent implements OnInit()
.
The jquery component I am trying to embed into Angular is located at https://jsfiddle.net/brohjoe/zgc0n1q5/1/
The HTML was entered into app.component.html
. I deleted references to the script src because the minified jquery library was listed in angular.json
as mentioned and the custom.js code was embedded in app.component.ts
as mentioned above.
After running localhost:4200, the only ui elements that will display are the dropdowns with no data.