UNPKG

angular-http-status

Version:

AngularJS stuff to easily convert status text into its HTTP code and vice versa

21 lines (16 loc) 544 B
angular .module('demo-angular-http-status', ['ngHttpStatus']) .controller('demoCtrl', function(HttpCodes, HttpStatus) { this.code = 200; this.text = 'Ok'; this.statusCodes = HttpCodes; this.toString = function(status) { return HttpStatus.toString(status); }; this.toStatus = function(meaning) { var statusText = meaning.toUpperCase().replace(' ', '_'); return angular.isDefined(HttpCodes[statusText]) ? HttpCodes[statusText] : '<< Invalid key ' + statusText + ' >>' } });