Monday, November 30, 2015

Exception handling in Angular using $exceptionHandler

Handling uncaught exception

Edit in plnkr

Steps involved
  • Use $provide service in config section as shown below
Note:We need to customize the handler action
In the example shown below $scope is not defined. This exception is handled and alert is shown to the user

var myAppModule = angular.module('myApp', []);
        .config(function ($provide) {
                    function ($delegate) {
                        return function (exception, cause) {
                              $delegate(exception, cause);
        .controller('Details', function () {
            $scope.FirstName = "Prathap";


No comments:

Post a Comment