Angular 2 template - Problem running jquery in a view thats not part of the Angular App #755

Closed
opened 2025-08-09 17:17:33 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @jagmagh on 5/17/2017

I have created a project using the Angular 2 template of JavascriptServices.

In that template, based on my understanding of webpack configuration, the vendor.js file already includes JQuery. I also opened up the file generated and I can definitely find JQuery included in the file generated by the development mode of webpack.

This vendor.js file is included in my _Layout.cshtml as I need it for all my views.
The order of loading is as given below

<script src="~/dist/vendor.js" asp-append-version="true"></script>
<script src="~/dist/site.js" asp-append-version="true"></script>

In the site.js file, I get the dreaded "Uncaught ReferenceError: $ is not defined" error


$(document).ready(function() {

when trying to access the the JQuery $ object as it doesnt recognize it.

Since vendor.js has already jquery in it, I was expecting to be able to use $ in my site.js
Am i missing something here? or is there something fundamentally wrong in my understanding of how all of this fits together?

Note : I am not trying to use jQuery $ inside of my Angular application itself. This site.js is just part of my Razor view.

*Originally created by @jagmagh on 5/17/2017* I have created a project using the Angular 2 template of JavascriptServices. In that template, based on my understanding of webpack configuration, the vendor.js file already includes JQuery. I also opened up the file generated and I can definitely find JQuery included in the file generated by the development mode of webpack. This vendor.js file is included in my _Layout.cshtml as I need it for all my views. The order of loading is as given below ``` <script src="~/dist/vendor.js" asp-append-version="true"></script> <script src="~/dist/site.js" asp-append-version="true"></script> ``` In the site.js file, I get the dreaded "`Uncaught ReferenceError: $ is not defined`" error ``` $(document).ready(function() { ``` when trying to access the the JQuery $ object as it doesnt recognize it. Since vendor.js has already jquery in it, I was expecting to be able to use $ in my site.js Am i missing something here? or is there something fundamentally wrong in my understanding of how all of this fits together? Note : I am not trying to use jQuery $ inside of my Angular application itself. This site.js is just part of my Razor view.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#755
No description provided.