Skip to content

Instantly share code, notes, and snippets.

@saurabhpati
Created June 10, 2018 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saurabhpati/83ad684ff478091ccce338811505d865 to your computer and use it in GitHub Desktop.
Save saurabhpati/83ad684ff478091ccce338811505d865 to your computer and use it in GitHub Desktop.
A pragmatic suspiciousController
function suspiciousController($scope, $log, suspiciousService) {
var options = {
throwException: false // change to false in case no exception is to be thrown.
};
$scope.doImportantStuff = function () {
try {
suspiciousService.doVeryImportantStuff(options)
.then(function (promisedData) {
// Do something with promised data.
$log.log('Doing something with promised data', promisedData);
})
.catch(function (noCantDo) {
$log.log(noCantDo);
});
} catch (error) {
$log.log(error);
// Submit this error to your api which logs this error using $http service.
}
}
}
suspiciousController.$inject = ['$scope', '$log', 'suspiciousService']
angular
.module('demoModule')
.controller('suspiciousController', suspiciousController);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment