I would change the style of p-autocomplete component depending on variable value
I have a toggle input that determine whether my variable is true or false
<div class="switch-inner">
<p [ngClass]="{'businessG': !toggle }" class ="toggle-inline ">Business group</p>
<div class="toggle-btn toggle-inline">
<label class="switch">
<input type="checkbox" [(ngModel)]="toggle">
<span class="slider round"></span>
</label>
</div>
<p [ngClass]="{'borrower': toggle }" class="toggle-inline">Borrower</p>
</div>
Then I use this value to set the style of my suggestion items background on hover.
actually I'm using a default color that I have changed by using ::ngdeep
::ng-deep .ui-autocomplete-list-item:hover{
background-color: #24B3C7; // would change this to another color
font-family: 'BNPPSans';
border-radius: 0
}
I would change the background color depending on the value of the toggle variable.
Here's my component html
<div class="container" id ="inputSearchPage">
<div class="search-input col-md-6 col-sm-6 ui-fluid" >
<p-autoComplete [(ngModel)]="text" [suggestions]="results" (completeMethod)="search($event)"
emptyMessage={{noBorrowerResult}}
[minLength]="3"
[size] = "40"
field = "name"
>
<ng-template let-elm pTemplate="item" class="suggestion-item" >
<div >{{elm.name}} ( ID: {{elm.code}} )</div>
<div class="add-button">+</div>
</ng-template>
</p-autoComplete>
</div>
How can I set the background color depending to the toggle value ? ( if true set ::ng-deep .ui-autocomplete-list-item:hover backgroud-color to color 1 else set to color 2 )