You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[style.width.px]="model?.cells[r][c]?.width" and [attr.width]="model?.cells[r][c]?.width" is work for me.
But I think this should be a mistake or why doesn't this work in Angular9?
tl;dr; this is not the valid syntax and it just "happened to work" in previous versions of Angular. As @DreamLi1314 suggested you need to use one of:
[style.width.px]="expression" if you want to bind to the CSS style property (probably this is what you want);
[att.width]="expression + 'px'" if you want to bind to the width attribute
What was happening with the VE attribute parser that any suffix would be dropped without any warning ( https://stackblitz.com/edit/angular-9qzvjk) which isn't greatest user experience... I'm going to keep this issue open so we can decide what to do here (probably error when detecting such usage pattern).
Activity
DreamLi1314 commentedon Mar 26, 2020
[style.width.px]="model?.cells[r][c]?.width"and[attr.width]="model?.cells[r][c]?.width"is work for me.But I think this should be a mistake or why doesn't this work in Angular9?
pkozlowski-opensource commentedon Mar 26, 2020
tl;dr; this is not the valid syntax and it just "happened to work" in previous versions of Angular. As @DreamLi1314 suggested you need to use one of:
[style.width.px]="expression"if you want to bind to the CSS style property (probably this is what you want);[att.width]="expression + 'px'"if you want to bind to the width attributeWhat was happening with the VE attribute parser that any suffix would be dropped without any warning ( https://stackblitz.com/edit/angular-9qzvjk) which isn't greatest user experience... I'm going to keep this issue open so we can decide what to do here (probably error when detecting such usage pattern).
DreamLi1314 commentedon Mar 27, 2020
ok, thanks.
8 remaining items
angular-automatic-lock-bot commentedon Aug 8, 2022
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.