Good evening. It is impossible to make a change in the color and text of the button when pressed. A boolean comes from the server, depending on its value a certain button is displayed.
<tr ng-repeat="employee in allEmployee"> <td> <button style="width:80px;height:35px" ng-click="changeEmployeeStatus(employee)" ng-class="{'btn btn-success' : employee.active, 'btn btn-danger' : !employee.active}" type="button">{{employee.active? 'Active': 'UnActive'}} </button> </td> </tr> How to make it so that when pressed not only the function changeEmployeeStatus(employee) is changeEmployeeStatus(employee) , but also the color and the label of the button change?
changeEmployeeStatus (employee):
Controller:
$scope.changeEmployeeStatus = function (employee) { staffManagementService.changeEmployeeStatus(employee.email).success(function (data) { console.log(data); }); }; service:
service.changeEmployeeStatus = function (email) { console.log(email) http({ method : 'GET', url : '/admin/changeEmployeeStatus', params : {email:email} }).success(function (data, status, headers) { console.log(data); return data; }); };