I have an angular module / factory like this:
var app = angular.module('webportal', ['vr.directives.slider', 'angular-flexslider', 'LocalStorageModule', 'multi-select']);
app.factory('portal', ['uri', function (uri) {
portal = {};
portal.getURLParameter = function (name) {
var hash;
var vars = [];
var indexOfQuestion = window.location.href.indexOf('?');
if (indexOfQuestion != -1) {
var hashes = window.location.href.slice(indexOfQuestion + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
if (typeof name == 'undefined')
vars.push(hashes[i]);
else {
hash = hashes[i].split('=');
if (hash[0] = name)
return hash[1];
}
}
}
};
return portal;
}]);
Now i am trying to call the getURLParameter
from outside angular, like this:
angular.injector(['webportal']).get('portal').getURLParameter('blah');
Of course that does not work and fails with:
Error: [$injector:modulerr] Failed to instantiate module webportal due to: [$injector:modulerr] Failed to instantiate module vr.directives.slider due to: [$injector:modulerr] Failed to instantiate module ngTouch due to: [$injector:unpr] Unknown provider: ngClickDirectiveProvider http://errors.angularjs.org/1.2.25/$injector/unpr?p0=ngClickDirectiveProvider minErr/......
So can anyone tell me what is the proper way to call this?
angular.injector(['ng','webportal']).get
– PSLng
– PSL