Recently I started making my own application on AngularJS. At the early stages I faced a problem and I haven't been able to solve it for quite a long time. In my app I use ng-view and angular-route to load different parts from .html files. In most of them I require third-party libraries, like Loading Bar. I add script src in the end of body. The thing is, like with that Loading Bar, if I use it OUTSIDE ng-view in index.html it works perfectly fine. But if I put elements which require this library in other .html files and are then loaded into ng-view the script does not work. Here's the example:
<body>
<div ng-view></div>
<div
class="ldBar label-center"
style="width:50%;height:50%;margin:auto"
data-value="35"
data-preset="circle"
></div>
<script src="libs/loading-bar/loading-bar.js"></script>
</body>
This code works as intended. But if I load the code via ng-view like this:
<div ng-view>
<div
class="ldBar label-center"
style="width:50%;height:50%;margin:auto"
data-value="35"
data-preset="circle"
></div>
</div>
It doesn't work. As far as I understand it, I need to initialize the library script AFTER the ng-view loads. Or maybe the problem is somewhere else. There are a lot of similar questions here, but the answers are not entirely clear to me. Most of them are about creating custom factory or service. But how am I supposed to do it with a third-party library? If it's possible, I would be grateful if someone would show me how exactly solve this problem using the same Loading Bar. Thank you.