After creating a versatile template case component to be used across multiple cases, I implemented ng-content select=""
to utilize it as a template.
Although it functions well, there are some limitations in its performance. For instance:
- I have a div with a background image whose styling is defined within the template component:
<div class="front-image min-vh-100 min-vw-100" [style.transform]="'scale(' + scale + ')'">
</div>
To transform this into a reusable template, I substituted the above code with:
<ng-content select=".front-image"></ng-content>
and incorporated the template in another component like so:
<app-case-template *ngIf="cases[3] as case">
<div class="front-image min-vh-100 min-vw-100" [ngStyle]="{ 'background-image': 'url(' + case.image + ')'}"
[style.transform]="'scale(' + scale + ')'">
</div>
</app-case-template>
Is there a way for the template to consistently inherit its styling from the template component? Currently, I had to specify its styling within the new component for it to function properly. Moreover, [style.transform]
ceased functioning.
Could there possibly be a workaround?