diff --git a/src/alert/alert.js b/src/alert/alert.js index b1fda4ec83..39a2996c4c 100644 --- a/src/alert/alert.js +++ b/src/alert/alert.js @@ -7,11 +7,14 @@ angular.module('ui.bootstrap.alert', []) .directive('alert', function () { return { - restrict:'EA', - controller:'AlertController', - templateUrl:'template/alert/alert.html', - transclude:true, - replace:true, + restrict: 'EA', + controller: 'AlertController', + controllerAs: 'alert', + templateUrl: function(element, attrs) { + return attrs.templateUrl || 'template/alert/alert.html'; + }, + transclude: true, + replace: true, scope: { type: '@', close: '&' diff --git a/src/alert/docs/readme.md b/src/alert/docs/readme.md index 4bc6f5242c..ef8c30f1f8 100644 --- a/src/alert/docs/readme.md +++ b/src/alert/docs/readme.md @@ -5,3 +5,5 @@ This directive can be used to generate alerts from the dynamic model data (using The presence of the `close` attribute determines if a close button is displayed. The optional `dismiss-on-timeout` attribute takes the number of milliseconds that specify timeout duration, after which the alert will be closed. + +The optional `template-url` attribute allows the user to override the default template with a custom template on an instance by instance basis diff --git a/src/alert/test/alert.spec.js b/src/alert/test/alert.spec.js index 271833309a..152bb106e8 100644 --- a/src/alert/test/alert.spec.js +++ b/src/alert/test/alert.spec.js @@ -1,14 +1,15 @@ describe('alert', function () { - var scope, $compile; + var scope, $compile, $templateCache; var element; beforeEach(module('ui.bootstrap.alert')); beforeEach(module('template/alert/alert.html')); - beforeEach(inject(function ($rootScope, _$compile_) { + beforeEach(inject(function ($rootScope, _$compile_, _$templateCache_) { scope = $rootScope; $compile = _$compile_; + $templateCache = _$templateCache_; element = angular.element( '