I need to define for my html page that load a javascript external file only when the variable $scope.jsallowed
is set to true
, So I tried this code: (My page is based on AngularJS )
In html :
<script src="assets/js/slider.min.js" data-ng-if="jsallowed"></script>
In JS:
$scope.jsallowed = false;
(Note that I set the application and controller and... but I just included codes you need here.) But the problem is, My javascript file loads yet. While it should not. How can I improve my code to prevent loading it until I set jsallowed variable to true?