Skip to content

Instantly share code, notes, and snippets.

@ry8806
Last active January 20, 2016 13:13
Show Gist options
  • Select an option

  • Save ry8806/26d267412a6c4eaad0f0 to your computer and use it in GitHub Desktop.

Select an option

Save ry8806/26d267412a6c4eaad0f0 to your computer and use it in GitHub Desktop.
An Angular Module for handling errors
angular.module('Errors', ['jqueryDialog'])
.service('ErrorService', ['$templateRequest', 'dialogService', function ($templateRequest, dialogService) {
// The template (which references the controller)
var templateUrl = "../error-template.html";
// Request the template and do nothing - so it's in the cache in case we lose internet connection later
$templateRequest(templateUrl);
// Now show the template in a dialog box
this.ShowError = function (info) {
return dialogService.open(1, templateUrl, { info },
{
modal: true,
resizable: false,
draggable: false,
minWidth: 450,
show: "fade",
hide: "fade",
});
};
}])
.controller('ErrorController', ['$scope', 'dialogService', function ($scope, dialogService) {
// The jqueryDialog module automatically puts our info object on the Controller's $scope.model
$scope.Info = $scope.model;
$scope.Ok = function () {
dialogService.close(1);
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment