Angular and jQuery script order

6,996 views
Skip to first unread message

Marcin Cetnarski

unread,
Nov 14, 2012, 4:58:45 AM11/14/12
to ang...@googlegroups.com
Hi,

I found weird behavior for form validation when ng-switch and ng-repeat is used. Here is link for example http://plnkr.co/2LRqYQ 
When jQuery is loaded before Angular, FormController.$removeControl function is not called on switch but when you change the order of scripts inclusion then it's called properly.
I know there are similar issues reported like https://groups.google.com/forum/?fromgroups=#!topic/angular/Hao7k4xxhIU - Peter's patch also deals with improper $removeControl call.

I didn't find any instructions in angular docs about correct scripts include order (first angular then jquery) but I found this hint http://stackoverflow.com/questions/12822862/getting-angular-ui-to-work which stays against my findings.

dengh...@gmail.com

unread,
Nov 14, 2012, 9:17:31 AM11/14/12
to ang...@googlegroups.com
angular.js will use jQuery if it's include first. Otherwise it will use it's own jqLite. 
I'm not sure what will happen if you include jQuery after angular.js. 

Peter Bacon Darwin

unread,
Nov 14, 2012, 9:48:42 AM11/14/12
to ang...@googlegroups.com
If you load jQuery after AngularJS, AngularJS attaches itself to jqLite but you can still access jQuery through $.  This is not a good situation to be in.  If you are going to use jQuery then you should always load it before AngularJS.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
 
 

Marcin Cetnarski

unread,
Nov 14, 2012, 3:12:38 PM11/14/12
to ang...@googlegroups.com
ok, if jQuery will be loaded first then validation of form is broken - FormController.$removeControll is not called - see my example in http://plnkr.co/2LRqYQ - I'll report a bug then.

shubha...@daffodilsw.com

unread,
Apr 22, 2015, 2:31:40 AM4/22/15
to ang...@googlegroups.com
Hello I have The following file Please suggest me the correct order of these files
<head>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
 <script src="schscript/angular.js"> </script>
<script src="schscript/schAngularController.js">   </script>
  
   </head>

RS_developer

unread,
Mar 8, 2016, 2:38:17 PM3/8/16
to AngularJS
Hi, I am having issues adding angular and require.js. I have one application where I have require.js. Adding a control which uses angular. Instead of appliying angular in whole application, i want to use in that piece only. But require.js conflicts with the module.
Any suggestions?
Reply all
Reply to author
Forward
0 new messages