I'm trying to figure out how to handle an object called xyzApi in my code. This object is defined outside of my angular code and contains classes and utility methods that I want to make accessible to the rest of my API.
This is what it looks like (in a nutshell):
var xyzApi = xyzApi || {
entities : new function () {
this.oAuthToken = function (token, expires, type) {
this.token = token;
this.expires = expires;
this.type = type;
this.toString = function () {
if (this.token != null)
return this.type + ' ' + this.token;
return null;
};
};
}
};
Now, within my angular service layer, I've created a provider named xyzApi as well. Here's a snippet of how it's set up:
(function () {
angular.module('xyzDataWebServices').provider('xyzApi', function () {
var baseUrl;
this.setBaseUrl = function (value) {
baseUrl = value;
};
this.$get = ['$log', 'baseRequest', 'xyzApiContext', 'xyzApiAuthentication', 'xyzApiLibrary', function xyzApiFactory($log, baseRequest, xyzApiContext, xyzApiAuthenication, xyzApiLibrary) {
baseRequest.setServiceUrl(baseUrl);
var factory = {
context: xyzApiContext,
authentication: xyzApiAuthenication,
library: xyzApiLibrary
}
return factory;
}];
});
})();
My question is, when using the provider in my code, will the original object automatically merge with the provider, or will being in scope of a controller using the provider hide the original object?