Created
November 28, 2012 17:40
-
-
Save davisford/4162773 to your computer and use it in GitHub Desktop.
Promises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// with promise | |
app.controller('FooCtrl', ['$scope', 'rpc', function ($scope, rpc) { | |
var promise = rpc.exec('foo.get'); | |
promise.then( | |
/* success */ function (foos) { console.log('got some foos', foos); }, | |
/* failure */ function (err) { conosle.log('got an error', err); } | |
); | |
}]); | |
// without a promise | |
app.controller('FooCtrl', ['$scope', 'rpc', function ($scope, rpc) { | |
rpc.exec('foo.get', function (err, foos) { | |
if (err) { return console.log('got an error', err); } | |
console.log('got some foos', foos); | |
}); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment