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:
@ -11,12 +11,12 @@ process.angular_build = true;
|
|||||||
|
|
||||||
/* global angular */
|
/* global angular */
|
||||||
angular.module('elasticsearch', [])
|
angular.module('elasticsearch', [])
|
||||||
.factory('esFactory', ['$http', '$q', function ($http, $q) {
|
.factory('esFactory', ['$injector', '$q', function ($injector, $q) {
|
||||||
|
|
||||||
var factory = function (config) {
|
var factory = function (config) {
|
||||||
config = config || {};
|
config = config || {};
|
||||||
config.connectionClass = AngularConnector;
|
config.connectionClass = AngularConnector;
|
||||||
config.$http = $http;
|
config.$injector = $injector;
|
||||||
config.defer = function () {
|
config.defer = function () {
|
||||||
return $q.defer();
|
return $q.defer();
|
||||||
};
|
};
|
||||||
|
|||||||
20
src/lib/connectors/angular.js
vendored
20
src/lib/connectors/angular.js
vendored
@ -12,16 +12,24 @@ var ConnectionFault = require('../errors').ConnectionFault;
|
|||||||
|
|
||||||
function AngularConnector(host, config) {
|
function AngularConnector(host, config) {
|
||||||
ConnectionAbstract.call(this, host, config);
|
ConnectionAbstract.call(this, host, config);
|
||||||
this.defer = config.defer;
|
var connector = this;
|
||||||
this.$http = config.$http;
|
|
||||||
if (this.host.auth) {
|
config.$injector.invoke(function ($http, $q) {
|
||||||
this.$http.defaults.headers.common.Authorization = 'Basic ' + (new Buffer(this.host.auth, 'utf8')).toString('base64');
|
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);
|
_.inherits(AngularConnector, ConnectionAbstract);
|
||||||
|
|
||||||
AngularConnector.prototype.request = function (params, cb) {
|
AngularConnector.prototype.request = function (params, cb) {
|
||||||
var abort = this.defer();
|
var abort = this.$q.defer();
|
||||||
|
|
||||||
this.$http({
|
this.$http({
|
||||||
method: params.method,
|
method: params.method,
|
||||||
url: this.host.makeUrl(params),
|
url: this.host.makeUrl(params),
|
||||||
|
|||||||
Reference in New Issue
Block a user