Skip to content

Instantly share code, notes, and snippets.

View blin86's full-sized avatar

Bryan Lin blin86

View GitHub Profile
@blin86
blin86 / promise-sample.js
Last active December 11, 2016 14:41
Constructing and using an AngularJS promise
angular.module('app', [])
.factory('FakeAmazonService', function($http, $q) {
return {
validateShippingAdddress: function(address) {
var deferred = $q.defer();
$http.post('/api/address/validate', address)
.then(function(resp) {
deferred.resolve({ success: true, data: resp});
}),
function(error) {