1.

How will you hide an HTML tag element on click of a button click in AngularJS? Write a program for the same.

Answer»

This can be achieved by making use of the ng-click DIRECTIVE that controls the condition USED for manipulating the display of the tag in the ng-hide directive.

<!DOCTYPE HTML><html><head> <meta chrset="UTF 8"> <title>Button Click Hide</title></head><body> <script src="https://code.angularjs.org/1.6.9/angular.js"></script> <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <div ng-app="buttonDemo" ng-controller="buttonDemoController"> <button ng-click="hideTag()">Hide IntervieBit</button> <div ng-hide="hideFlag">InterviewBit</div> </div> <script type="text/javascript"> var app = angular.module('buttonDemo',[]); app.controller('buttonDemoController',function($SCOPE){ $scope.hideFlag = false; $scope.hideTag = function(){ $scope.hideFlag = true; } }); </script></body></html>


Discussion

No Comment Found