Skip to content

Instantly share code, notes, and snippets.

@alatzl
Last active August 29, 2015 14:19
Show Gist options
  • Save alatzl/f26d9503bc46ff8a8dd4 to your computer and use it in GitHub Desktop.
Save alatzl/f26d9503bc46ff8a8dd4 to your computer and use it in GitHub Desktop.
Writing Angular with Migration in Mind: Ex. 1
angular.module('myModule')
.service('addresses', ['addressService', '$q', function(addressService, $q) {
this.prefix = 'My Address: ';
this.printAddress = function() {
var deferred = $q.defer(),
self = this;
addressService.getFullAddress(function(addr) {
deferred.resolve(self.prefix + addr);
}, deferred.reject);
return deferred.promise;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment