Issue
What is the best practice for string interpolation in attribute in Angular 6?
I have this code:
<div class="container" [ngStyle]="{'grid-template-rows': 'repeat(' + value + ', 1fr) [last-line]'}">
I want to use something like 'repeat(${value})'
with backtick
Solution
You can try to move the functionality to your component and use backticks there:
calculateStyle(value: string): string {
return `repeat(${value}, 1fr) [last-line]`;
}
and in template:
<div class="container" [ngStyle]="{'grid-template-rows': calculateStyle(value)}">
Answered By - Ludevik
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.