Error: $ is not defined in Angular Universal

Viewed 234

I am using jQuery in my Angular Universal project.

I have installed jQuery and invoked it in angular.json file as follows :

"scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js",
              "node_modules/tinymce/tinymce.min.js"
            ]

I have declared the variables in app.component.ts as follows:

declare var $: any;

But when I run the app, I get following list of errors:

ReferenceError: $ is not defined
TypeError: window.matchMedia is not a function
ReferenceError: location is not defined

Everything was working fine in the regular Angular app (without server side), but not working in the Universal app (with server side).

0 Answers
Related