I am working on an Angular app using PrimeNG. I am asking if I can conditionally add a PrimeNG component attribute based on the value of a property. Into my HTML page I have something like this:
<span [ngClass]="{'isMobileCalendar' : (isMobile2 | async)}">
<p-calendar monthNavigator="true"
yearRange="1990:2060"
yearNavigator="true"
formControlName="date"
[touchUI]="true"
[style]="{'width':'85%'}">
</p-calendar>
</span>
As I can see at the moment I have this attribute set to true: [touchUI]="true". I also have this (isMobile2 | async) variable defined in my Angular component and obtained using the |async.
I need to implement the following behavior:
- If (isMobile2 | async) value is true --> set: [touchUI]="true"
- If (isMobile2 | async) value is false --> set: [touchUI]="false"
Is it possible to implement this behavior inline instead to use ngIf and define twice p-calendar components (based on the value of isMobile2 | async value)? If it could be done inline it will be nice and neat
Have you tried below?
Edit 1: How about this one ?