Promises in Angular.JS
By using Promises we can execute a function asynchronously. we can use promises to specify what to do when a operation is success or failed. We have $q built in keyword in angular js for promises. let's create a example :
Read full blog at our highly specific C, PHP, Java, iPhone, Javascript Questions, about the topic described above "Promises in Angular.JS". You can also learn much more about different programming technologies and can enhance your tech skills.
- .service('drawHomeCardService', function(apiCallFactory, $q) {
- this.getTheLogo = function() {
- var deferred = $q.defer();
- apiCallFactory.getData().success(function(response) {
- var logo = response[2].businessInfo.logoFilePath;
- var logoFilePath = 'https://oyokeydev.s3.amazonaws.com/' + logo;
- deferred.resolve(logoFilePath);
- }).error(function(response) {
- console.log('Something went wrong');
- deferred.reject('Something went wrong');
Read full blog at our highly specific C, PHP, Java, iPhone, Javascript Questions, about the topic described above "Promises in Angular.JS". You can also learn much more about different programming technologies and can enhance your tech skills.