Friday 29 September 2017

Jquery is not working with AngularJS.

In this article we will discuss about Why Jquery is not working with AngularJS.

The main Problem behind this issue is we are trying to Use both AngularJs and Jquery Simultaneously and Problem arises when we used angularJs Previously and now we are trying to use Jquery at that time already $ is already defined in AngularJs and again we are trying to define $ in Jquery, due to which the Jquery will not work in AngularJs.

To resolve the issue we need to use $.noConflict(); in Jquery So that our AngularJs as well as Jquery both will work fine.

Example:-
--------------

Let us consider i have a project and where i have master page(Layout1.cshtml) and in that i used AngularJS and which is absolutely working fine.

After that take one Index.cshtml page and which includes master page(Layout.cshtml) and there i want to Use Jquery but if i used directly then it will show the $ is not a function error in your console window of Browser.

To resolve this error we need to use $.noConflict(); in the pageload in Index.cshtml page so that Jquery also works with AngularJS.



0 comments:

Post a Comment