Last active
January 20, 2016 13:13
-
-
Save ry8806/26d267412a6c4eaad0f0 to your computer and use it in GitHub Desktop.
An Angular Module for handling errors
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
| 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