Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(alert): correct binding of alert type class
Browse files Browse the repository at this point in the history
Regression from #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 #2145
Closes #2146
  • Loading branch information
chrisirhc authored and pkozlowski-opensource committed May 5, 2014
1 parent 44e7d77 commit aa188ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/alert/test/alert.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ describe('alert', function () {
expect(alerts.eq(2)).toHaveClass('alert-warning');
});

it('should respect alert type binding', function () {
var alerts = createAlerts();
expect(alerts.eq(0)).toHaveClass('alert-success');

scope.alerts[0].type = 'error';
scope.$digest();

expect(alerts.eq(0)).toHaveClass('alert-error');
});

it('should show the alert content', function() {
var alerts = createAlerts();

Expand Down
2 changes: 1 addition & 1 deletion template/alert/alert.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="alert" ng-class="{'alert-{{type || 'warning'}}': true, 'alert-dismissable': closeable}" role="alert">
<div class="alert" ng-class="['alert-' + (type || 'warning'), closeable ? 'alert-dismissable' : null]" role="alert">
<button ng-show="closeable" type="button" class="close" ng-click="close()">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
Expand Down

0 comments on commit aa188ae

Please sign in to comment.