Question:

How do you hide an HTML element via a button click in AngularJS?

Answer:

You can do this by using the ng-hide directive in conjunction with a controller we can hide an HTML element on button click.

<div ng-controller="MyCtrl">
	<button ng-click="hide()">Hide element</button>
	<p ng-hide="isHide">Hello World!</p>
</div>
function MyCtrl($scope){
	$scope.isHide = false;
	$scope.hide = function(){
		$scope.isHide = true;
	}
}

Keywords:

© 2017 QuizBucket.org