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

Alert type expressions are ignored when applied in an event method (always shows warning-style) #2145

Closed
olada opened this issue May 4, 2014 · 6 comments

Comments

@olada
Copy link

olada commented May 4, 2014

I came across following issue, which I have recreated in following plunker: http://plnkr.co/edit/iKUc68725E7daDKKbGW6?p=preview

It shows a button which will trigger an alert.
The alert is customized by data coming from the controller.

When setting the data directly in the controller, the alert is customized just fine.
E.g.
$scope.alert = {type: "danger", message: "This is a danger-alert"};
shows a correct red alert box.

However, when the same object is created from inside the submit-method, only the text will be applied and the design of the alert box will be rendered using "warning"-style (yellow-ish).

Does this have something to do with the latest modifications to the scope of the alert template?
This has been driving me nuts for the few past hours (I have just started with Angular / ui-bootstrap).

Feel free to fiddle around with the plunker link and uncomment the first $scope.alert = { .... occurence while commenting the later one.

TLDR:
Alert-Markup using {{alert.message}} fails when the alert object is changed during a form-submit event, as it will always show type = warning, even though the generated markup shows traces of the correct type (contains class alert-danger within ng-class attribute)

I hope the issue is somewhat understandable

@chrisirhc
Copy link
Contributor

Good catch. Looks like 794954a broke it. Using ng-if instead of ng-show is a workaround.

chrisirhc added a commit to chrisirhc/angular-ui-bootstrap that referenced this issue May 5, 2014
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
@bekos
Copy link
Contributor

bekos commented May 5, 2014

Hmm, I didn't know that type can change after an alert is created! Seems that I broke it then :-)

@AnthonySteele
Copy link

This seems to be still an issue in angular-bootstrap 0.11

This breaks my app as an exception is thrown while angular is parsing ui-bootstrap-tpls.js and generating a class name of alert-'info' which is not syntactically valid.

I have verified that angular-bootstrap 0.10 does not have this problem, and that applying the change above also fixes it.

@pkozlowski-opensource
Copy link
Member

@AnthonySteele this fix wasn't part of 0.11.0, it will be released with 0.12.0.

@AnthonySteele
Copy link

Yep, we will stay on 0.10 until 0.12 is out, as 0.11 is not usable for us.

@rutwickg
Copy link

@chrisirhc Plus one for ng-if. Doesn't work with ng-show for dynamic alerts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants