I have a onclick event where I bootstrap a angular module (This is the only way it can be done on the platform I am working on). Now this onclick event on the UI page can be click X times. The first time it is clicked the angular module is correct loaded and I can the see the controller working. Now when I click second time it throws an error.
OnClickEvent() {
//call ui page (which contains angular script)
}
Angular script
angular.module('myApp', [])
.factory('facotry', ['$http', function($http) {
}])
.controller('controller', function($scope, $attrs, $http) {
});
try{
angular.module('myApp');
}catch(e){
angular.bootstrap(document, ["myApp"]);
}
The error that I get
WARNING: Tried to load angular more than once.
VM65046:6Uncaught Error: [ng:btstrpd] http://errors.angularjs.org/1.6.1/ng/btstrpd?p0=document
How do I make sure that once the module is loaded it is not loaded again on click unless I refresh the page or something ?
Tried but not working
try{
angular.module('myApp');
}catch(e){
angular.bootstrap(document, ["myApp"]);
}