I am trying to load an external JS file based dynamically in my JS.
I have created a service to do it
angular.module('myApp').service('testService', function($http) {
var prefix;
//codes to determine what prefix is.
// It could be http://partnerapp.com/test or http://linkapp.com/test/libs/...etc
var url = prefix + '/js/test.js';
return $http({
method: 'GET',
url: url
}); //load JS file
});
in my main controller
angular.module('myApp').controller('myController', function($scope, testService){
//I am not sure how to load those js here.
})
Is there anyway I can load them in my case? Thanks a lot!