On my message i have a boolean property called state. (msg.state).
I am using an html template with a button on it. I havbe created two css classes, one with red background and one with green.
When the msg.state is true i want to use the .mygreen{} css class and use the .myred{} when is false.
i have tried with ng-class but with no results.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<!-- Calling jquery first -->
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<style>
.mygreen{
background-color:#00ff00;
color:red;
}
.myred{
background-color:#FF0000;
color:green;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark sticky-top" style="background-color: #0d223f;" >
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src="/images/logo.png" height="36">
</a>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
One of 2k
<button class="btn btn-primary" type="button" ng-class="msg.state==='true'?'myred':'mygreen'">Primaryh</button>
</div>
<div class="col-md-6">
2 of 2
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
</body>
</html>