In this example, we can change the color of text on ng-mouseleave event which is calling hideShow(isHide) function. If isHide is true then it will show the text "Green Color !" in green color and if isHide is false then "Red Color !" is shown in red color. Angularjs function for toggling the value of isHide: $scope.hideShow = function (val) { $scope.isHide = !val; }; and by default, on ng-init we setup isHide=true.
<!DOCTYPE html> <html xmlns=""> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src=""></script> </head> <body ng-app="app"> <div ng-controller="controllerName"> <div class="row"> <div class="col-md-6" ng-init="isHide=true"> <div ng-show="isHide" ng-mouseleave="hideShow(isHide)"><h3 style="color:green">Green Color !</h3></div> <div ng-hide="isHide" ng-mouseleave="hideShow(isHide)"><h3 style="color:red">Red Color !</h3></div> </div> </div> </div> <script> var app = angular.module("app", []); app.controller('controllerName', ['$scope', function ($scope) { $scope.hideShow = function (val) { $scope.isHide = !val; }; }]); </script> </body> </html>