I need to toggle CSS style, based on ng-click event.
First time user click ng-click element the style will be applied, the second time click on ng-click element the CSS not changed as expected toggle.
Find working code below,
HTML:
<h1 ng-style="myObj" ng-click="change()">Welcome</h1>
JavaScript:
app.controller("myCtrl", function ($scope) {
$scope.myObj = {
"color": "white"
}
$scope.change = function () {
$scope.myObj = {
"color": "red"
}
}
});
I need to toggle CSS class based on ng-click.
Anyone guide me how to archive the same.