javascript - Call to a function within $get of Provider modules causes TypeError -
this provider.
app.provider('cloudinarydetails', function(cloudinaryprovider){ function setcloudinarydetails(cloudinarydetails){ cloudinaryprovider.configure({ cloud_name: cloudinarydetails.cloud_name, api_key: cloudinarydetails.api_key }); } this.$get = function($http){ return { initialize: function(){ return $http.get('path/to/api').then(function(response){ setcloudinarydetails(response.data); }); } }; };
});
i calling initialize function in config module
app.config(function(cloudinarydetailsprovider){ cloudinarydetailsprovider.initialize(); });
console error:
[$injector:modulerr] failed instantiate module app due to: typeerror: cloudinarydetailsprovider.initialize not function
Comments
Post a Comment