Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot interpolate ({{}}) into class attribute of svg shape #8891

Closed
1 of 3 tasks
lsim opened this issue May 27, 2016 · 3 comments
Closed
1 of 3 tasks

Cannot interpolate ({{}}) into class attribute of svg shape #8891

lsim opened this issue May 27, 2016 · 3 comments

Comments

@lsim
Copy link

lsim commented May 27, 2016

  • I'm submitting a ...
  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

Current behavior
Cannot interpolate ({{}}) into the class attribute of an svg shape unless the same element also has [ngClass]="" on it.

Expected/desired behavior
Interpolation of arbitrary text into class attribute of any element ought to be possible - with or without [ngClass]=""

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via
    Reproduced here:
    https://plnkr.co/edit/mVe6NH?p=preview
  • What is the expected behavior?
    Both lines as well as the h1 should turn red as a result of having the 'red' class applied.
  • What is the motivation / use case for changing the behavior?
    .. there should be order in the world ¯_(ツ)_/¯
  • Please tell us about your environment:
  • Angular version: 2.0.0-rc1
  • Browser: [ Chrome 50 | Firefox 34 | Safari 9.0.3 ]
  • Language: [TypeScript]
@vicb
Copy link
Contributor

vicb commented May 27, 2016

You should bind to the attribute with SVG, ie [attr.class]="color"

@vicb vicb closed this as completed May 27, 2016
@lsim
Copy link
Author

lsim commented May 28, 2016

Thanks for that tip - it works like a charm!

I expect I won't be the last to be caught by surprise by this seeming inconsistency, though. I did spend a bit of time looking for special rules regarding svg in the angular docs - but came up empty handed. What did I miss?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants