I am developing dynamically style element feature in App server authentication and database search engine.
When
searchNoResult, UI is:
When click the button triggering
execSearch()event ->searchSuccessis true and templatesearchSuccessColortakes effect (text backgroundColor turns pink). However, I can’t seem to get the color dynamically styled:
I tried setting the template as below but doesn't work:
<button class="button"
[disabled] = "!enableSearch"
(click) = "execSearch()">Search State</button>
<div *ngIf = "searchSuccess; then searchSuccessColor else searchNoResult"></div>
<ng-template #searchNoResult>
<p>{{ stateSearchResult }}</p>
</ng-template>
<ng-template #searchSuccessColor>
<div [ngStyle]="{backgroundColor: 'pink'}"></div>
<p>{{ stateSearchResult }}</p>
</ng-template>
I tired component method as below but doesn't work:
setColor() {
return this.searchSuccess === true ? 'pink' : 'black';
}
Can someone help to identify what goes wrong?

