diff --git a/src/alert/alert.js b/src/alert/alert.js index 658878b691..507c2b7bf2 100644 --- a/src/alert/alert.js +++ b/src/alert/alert.js @@ -1,7 +1,13 @@ angular.module('ui.bootstrap.alert', []) -.controller('AlertController', ['$scope', '$attrs', function ($scope, $attrs) { +.controller('AlertController', ['$scope', '$attrs', '$timeout', function ($scope, $attrs, $timeout) { $scope.closeable = 'close' in $attrs; + + if ($scope.autoDismiss && $scope.close) { + $timeout(function () { + $scope.close(); + }, parseInt($scope.autoDismiss)); + } }]) .directive('alert', function () { @@ -13,7 +19,8 @@ angular.module('ui.bootstrap.alert', []) replace:true, scope: { type: '@', - close: '&' + close: '&', + autoDismiss: '@' } }; }); diff --git a/src/alert/test/alert.spec.js b/src/alert/test/alert.spec.js index fa0b4fb619..bc2106853e 100644 --- a/src/alert/test/alert.spec.js +++ b/src/alert/test/alert.spec.js @@ -5,10 +5,11 @@ describe('alert', function () { beforeEach(module('ui.bootstrap.alert')); beforeEach(module('template/alert/alert.html')); - beforeEach(inject(function ($rootScope, _$compile_) { + beforeEach(inject(function ($rootScope, _$compile_, $timeout) { scope = $rootScope; $compile = _$compile_; + timeout = $timeout; element = angular.element( '