aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Angularjs Button ng-click Event Directive Example

Jun 23, 2015

Here I will explain how to use ng-click event directive example in 
AngularJS for button click or show / hide div on button ng-click event in AngularJS or show / display or hide in AngularJS using button ng-click with example. By using “ng-show”, “ng-hide” properties in AngularJS we can show or hide div elements.

To show or hide div on button click in AngularJS we need to write the code like as shown below

// Show Div
$scope.showDiv = function () {
$scope.showhideprop = true;
// Hide Div
$scope.hideDiv = function () {
$scope.showhideprop = false;

If you want to check it in complete example you need to write the code like as shown below

<html xmlns="">
<title>Angularjs show or hide Div on button click</title>
<script src=""></script>
<script type="text/javascript">
var myApp = angular.module('sampleapp', [])
myApp.controller("expressionController", function ($scope) {
// Show Div
$scope.showDiv = function () {
$scope.showhideprop = true;
// Hide Div
$scope.hideDiv = function () {
$scope.showhideprop = false;

<form id="form1">
<div data-ng-app="sampleapp" data-ng-controller="expressionController">
<input type="button" ng-click="showDiv()" value="Show Div"/>   <input type="button" ng-click="hideDiv()" value="Hide Div"/> <br /><br />
<div style="padding:10px; border:1px solid black; width:30%; font-weight:bold" ng-show='showhideprop'>Hi Welcome to Angularjs... Hello World</div>

Live Demo

For live demo try to click on Show or Hide buttons to show or hide div

Hi Welcome to Angularjs... Hello World

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.