I'm trying to define a constant and inject that into a factory. My Constant is defined as follows:
angular.module("ContactApp").constant("BaseApiURL", "http://localhost:31523/api/");
My factory is defined as:
angular.module("ContactApp").factory('CustomerService', CustomerService);
//CustomerService.$inject = ['BaseApiURL']; Giving Error when this line is active.
function CustomerService(BaseApiURL, $resource) {
return $resource(BaseApiURL + 'Customers');
};
The above code is working, but don't I need to inject the constant as dependency into the factory method? I can inject the constant using the $inject into a controller but couldn't do that into the factory.
CustomerService.$inject = ['BaseApiURL'];? May be in your case it should beCustomerService.$inject = ['BaseApiURL','$resource'];.