From f561aa9e95be69818d9d538eebb00218d0d5f86b Mon Sep 17 00:00:00 2001 From: Wesley Cho Date: Sat, 3 Oct 2015 09:27:40 -0700 Subject: [PATCH] fix(alert): re-expose AlertController - Re-expose `AlertController` with deprecation message Closes #4525 --- src/alert/alert.js | 13 ++++++++++++- src/alert/test/alert.spec.js | 5 +++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/alert/alert.js b/src/alert/alert.js index b94e438793..e5ace4a081 100644 --- a/src/alert/alert.js +++ b/src/alert/alert.js @@ -32,9 +32,20 @@ angular.module('ui.bootstrap.alert') .value('$alertSuppressWarning', false) + .controller('AlertController', ['$scope', '$attrs', '$controller', '$log', '$alertSuppressWarning', function($scope, $attrs, $controller, $log, $alertSuppressWarning) { + if (!$alertSuppressWarning) { + $log.warn('AlertController is now deprecated. Use UibAlertController instead.'); + } + + angular.extend(this, $controller('UibAlertController', { + $scope: $scope, + $attrs: $attrs + })); + }]) + .directive('alert', ['$log', '$alertSuppressWarning', function($log, $alertSuppressWarning) { return { - controller: 'UibAlertController', + controller: 'AlertController', controllerAs: 'alert', templateUrl: function(element, attrs) { return attrs.templateUrl || 'template/alert/alert.html'; diff --git a/src/alert/test/alert.spec.js b/src/alert/test/alert.spec.js index 6073bfdef0..543a1a951b 100644 --- a/src/alert/test/alert.spec.js +++ b/src/alert/test/alert.spec.js @@ -166,7 +166,8 @@ describe('alert deprecation', function() { element = $compile(element)($rootScope); $rootScope.$digest(); - expect($log.warn.calls.count()).toBe(1); - expect($log.warn.calls.argsFor(0)).toEqual(['alert is now deprecated. Use uib-alert instead.']); + expect($log.warn.calls.count()).toBe(2); + expect($log.warn.calls.argsFor(0)).toEqual(['AlertController is now deprecated. Use UibAlertController instead.']); + expect($log.warn.calls.argsFor(1)).toEqual(['alert is now deprecated. Use uib-alert instead.']); })); });