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
bug(icon): custom directive cannot set svgIcon for mat-icon #20470
Comments
Looking at the code, it seems like we should extract the code in |
Moves some logic around so the icon can respond to changes in its state through plain property assignments, rather than going through Angular change detection cycle. This makes the component easier to extend. Fixes angular#20470.
The only way would be to define a setter for |
Moves some logic around so the icon can respond to changes in its state through plain property assignments, rather than going through Angular change detection cycle. This makes the component easier to extend. Fixes #20470.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Moves some logic around so the icon can respond to changes in its state through plain property assignments, rather than going through Angular change detection cycle. This makes the component easier to extend. Fixes angular#20470.
Reproduction
svgIcon
does not seem to work with Stackblitz, providing repo instead.Steps to reproduce:
yarn
ng serve
Expected Behavior
I tried to create a custom directive that would programmatically assign some icon name to the
svgIcon
input ofmat-icon
, depending on some global icon mapping configuration.This normally works for any component and I'd expect it should for
mat-icon
too.Example:
Actual Behavior
The behavior described above does not work with
mat-icon
, because the relevant logic is inngOnChanges
hook ofmat-icon
, which does not get triggered, unless at least oneInput
is present on the host component.components/src/material/icon/icon.ts
Lines 229 to 264 in 4f1238f
Workaround (ugly):
Instead of
add dummy/empty
svgIcon
Environment
NOTE: I can submit the PR for this, but would like some thoughts on that, maybe it's expected like this for some reason.
The text was updated successfully, but these errors were encountered: