how to render a javascript files after a view is render in Angular

Multi tool use
Multi tool use


how to render a javascript files after a view is render in Angular



I am new to angular and this is first time working with angular.js . I am trying to build an single page application in angular which has the following pages



All my pages have jquery script to handle modal popup form submission etc.



All of them work, but when i render those pages with ng-view inside index.html. Those script doesn't work,. They do not render as well.


ng-view



Can anyone please tell me how can i fix this issue or if there is any other way of doing the same keeping those jquery functions.



Here is my file structure
Index.html


<html>
......
<header>
<script src="<ANGULAR.JS>"></script>
<script src="<ANGULAR ROUTE.JS"></script>
<script src="<JQUERY>"></script>
<script defer src="<OTHER SCRIPTS>"></script>
</header>
<body>
<ng-view></ng-view>
</body>
</html>



home.html


<div>
<LOTS OF HTML CONTENTS>
</div>
<script src="<PATH TO JS FILE>"></script>





Did jquery imported first b4 angular?
– arnold emzi
Jul 1 at 9:54





No i imported jquery after anguler in the header
– user7747472
Jul 1 at 9:55





Try to switch the two if thats going to work
– arnold emzi
Jul 1 at 9:56





Now its working, do know how this happen though. Thank you a lot :))
– user7747472
Jul 1 at 10:03





Your angularjs loaded your html files through "ng-view" without jquery on it that is why your jquery script on it is having issue, remember jquery and angular is different modules they dont share the same scope
– arnold emzi
Jul 1 at 10:17




1 Answer
1



Switching places of angular with jQuery fixed the issue as suggested by @arnold thanks a lot :)






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

jaDV2azB0H6KH0B1,Quq pRq935rfJco,jCTgsFmJvmk1A7G
j54s91 5tkA,jox4iq4gIJLbdaio JlhTfjVqbKkQ VVs

Popular posts from this blog

PySpark - SparkContext: Error initializing SparkContext File does not exist

django NoReverseMatch Exception

List of Kim Possible characters