Answer the question
In order to leave comments, you need to log in
How to bring your module settings into AngularJS?
Hello! There was a need to move the functionality into a separate module. At first I just wanted a directive, but 2 services were needed for it, and here's the actual question - there are settings, for example, url for the request, time in milliseconds between requests, and the like, I found such a thing ,
angular.module('ngMyControl').value('options', {...})
- for me it’s the same thing, it turns out in the config of the application that will connect the module, you can somehow re-set the config via $provide, is there any example of implementing such functionality? I ask like thisvar myapp = angular.module('ngMyControl', []);
myapp.constant('MODULE_VERSION', '0.0.1');
myapp.value('options', {});
myapp.service('dataService', ['$http', 'options', function($http, options) {
this.request = function (query, hasTail) {
var params = {};
console.log(options);
params['query[]'] = query || [];
if (angular.isDefined(hasTail) && hasTail && params['query[]'].length) params.hasTail = true;
return $http.get('/api/Data', {
dataType: 'jsonp',
params: params
});
};
}]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question