Often in my templates, I find myself repeating this type of code:
<custom-button [align]="isMobile() ? 'center' : 'left'"></custom-button>
This also requires me to include a method in each component to determine whether it is mobile or not:
isMobile() {
return Util.isMobile();
}
It seems redundant to have this method in every component, but I haven't been able to find a simpler solution. While it could theoretically be achieved with CSS, in certain cases like the one presented, the alignment needs vary and cannot be controlled through external styling due to being nested within another component.
Any ideas on how to better address this issue?