In the code below, I am struggling with applying styling based on a dynamic value:
Pug:
div(ng-class="('{{selectedMessageType}}' == 'incoming')?'messageTypeSelected':'messageTypeNotSelected'")
CSS:
.messageTypeSelected{
background-color: #E8A83C;
color: #ffffff;
}
.messageTypeNotSelected{
background-color: #E4E4E4;
}
JS:
$scope.selectedMessageType = 'incoming';
$scope.changeMessageType = function(){
($scope.selectedMessageType == 'incoming')?$scope.selectedMessageType = 'outgoing':$scope.selectedMessageType = 'incoming';
};
The logic to replace {{selectedMessageType}}
appears to be correct as per my inspection in the browser's Inspector tool. However, the issue lies in the fact that the styling does not change when the value is updated.
Could you point out any potential errors or improvements in my code?