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

alert type interpolation forces alert type to be a string #2867

Closed
DamianEdwards opened this issue Oct 21, 2014 · 1 comment
Closed

alert type interpolation forces alert type to be a string #2867

DamianEdwards opened this issue Oct 21, 2014 · 1 comment

Comments

@DamianEdwards
Copy link

Seems that #1460 broke a pattern I was using for "strongly" typed alert types.

Essentially, if the type property of the alert is actually an object with toString overridden to provide the actual type string, the alert directive no longer resolves it correctly, resulting in an alert with no alert type class set.

Repro at http://plnkr.co/edit/GpvAnJpTHLHvcW83novF?p=preview

The repro also shows that manually using the same model property in a manually constructed alert (just using divs) works fine, it's the alert directive that can't use it.

Workaround for me for now is to change my binding to include the call to toString(), e.g.:

<alert ng-show="viewModel.alert" type="{{ viewModel.alert.type.toString() }}" close="viewModel.clearAlert()">
    {{ viewModel.alert.message }}
</alert>
@pkozlowski-opensource
Copy link
Member

Yes, this was the deliberate choice we've decided to go ahead with (https://github.com/angular-ui/bootstrap/blob/master/CHANGELOG.md#breaking-changes) as it seemed that many people were using fixed strings and were confused about the need to quote them.

Sorry about the additional work it caused on your side, but this change seems to be what works for most of the users.

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

No branches or pull requests

2 participants