Skip to content

Commit aa188ae

Browse files
chrisirhcpkozlowski-opensource
authored andcommitted
fix(alert): correct binding of alert type class
Regression from angular-ui#1745 as there's a double interpolation expected but ngClass doesn't support that. The attribute value of ngClass is only interpolated once and the interpolated expression is watched. Fixes angular-ui#2145 Closes angular-ui#2146
1 parent 44e7d77 commit aa188ae

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/alert/test/alert.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ describe('alert', function () {
5050
expect(alerts.eq(2)).toHaveClass('alert-warning');
5151
});
5252

53+
it('should respect alert type binding', function () {
54+
var alerts = createAlerts();
55+
expect(alerts.eq(0)).toHaveClass('alert-success');
56+
57+
scope.alerts[0].type = 'error';
58+
scope.$digest();
59+
60+
expect(alerts.eq(0)).toHaveClass('alert-error');
61+
});
62+
5363
it('should show the alert content', function() {
5464
var alerts = createAlerts();
5565

template/alert/alert.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="alert" ng-class="{'alert-{{type || 'warning'}}': true, 'alert-dismissable': closeable}" role="alert">
1+
<div class="alert" ng-class="['alert-' + (type || 'warning'), closeable ? 'alert-dismissable' : null]" role="alert">
22
<button ng-show="closeable" type="button" class="close" ng-click="close()">
33
<span aria-hidden="true">&times;</span>
44
<span class="sr-only">Close</span>

0 commit comments

Comments
 (0)