Created
June 10, 2018 16:51
-
-
Save saurabhpati/fca91e9a51861502e6ff2802074ea45d to your computer and use it in GitHub Desktop.
A suspicious controller where you may want to introduce error handling
This file contains hidden or 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
function suspiciousController($scope, $log, suspiciousService) { | |
var options = { | |
throwException: true // change to false in case no exception is to be thrown. | |
}; | |
$scope.doImportantStuff = function () { | |
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); | |
}); | |
} | |
} | |
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