updated angular build to add $invoke to the config (rather than and ) so that other components can define their dependencies in the component.

This commit is contained in:
Spencer Alger
2014-04-23 12:21:10 -07:00
parent 2104c692ab
commit c5ea877e3b
2 changed files with 16 additions and 8 deletions

View File

@ -11,12 +11,12 @@ process.angular_build = true;
/* global angular */
angular.module('elasticsearch', [])
.factory('esFactory', ['$http', '$q', function ($http, $q) {
.factory('esFactory', ['$injector', '$q', function ($injector, $q) {
var factory = function (config) {
config = config || {};
config.connectionClass = AngularConnector;
config.$http = $http;
config.$injector = $injector;
config.defer = function () {
return $q.defer();
};

View File

@ -12,16 +12,24 @@ var ConnectionFault = require('../errors').ConnectionFault;
function AngularConnector(host, config) {
ConnectionAbstract.call(this, host, config);
this.defer = config.defer;
this.$http = config.$http;
if (this.host.auth) {
this.$http.defaults.headers.common.Authorization = 'Basic ' + (new Buffer(this.host.auth, 'utf8')).toString('base64');
}
var connector = this;
config.$injector.invoke(function ($http, $q) {
connector.$q = $q;
connector.$http = $http;
if (connector.host.auth) {
connector.$http.defaults.headers.common.Authorization = 'Basic ' + (new Buffer(connector.host.auth, 'utf8')).toString('base64');
}
});
}
_.inherits(AngularConnector, ConnectionAbstract);
AngularConnector.prototype.request = function (params, cb) {
var abort = this.defer();
var abort = this.$q.defer();
this.$http({
method: params.method,
url: this.host.makeUrl(params),