AngularJs show hide on click


AngularJs show hide on click : It is very simple to call show hide on button click event in AngularJs. You can use ng-hide, ng-show to show hide the element. Here we are going to create a function and call this function on button click to hide show functionality in angularJs. Here we are going to explain the show hide functionality with example.


AngularJs show hide Div on click

Here is simple example of show hide on button click in AngularJs –

AngularJs show hide on click example

<script type="text/javascript">
angular.module('myApp', [])
.controller('myCtrl', function($scope) {
$scope.showHideDiv = function() {
    if(!$scope.myDiv){
    $scope.myDiv = true;
    }else{
     $scope.myDiv = false;
     }
}
});

</script>
<div ng-app="myApp" ng-controller="myCtrl">
<button ng-click="showHideDiv()">Show/Hide</div>

<div ng-show="myDiv">Div Show Hide Example......</div>


</div>

Advertisements

Add Comment

📖 Read More