AngularJS | ng-show vs ng-if
HTML
<div ng-app="angularjs-starter" ng-controller="MainCtrl">
<div class="item" ng-if="togglediv">Show (ng-if)</div>
<div class="item" ng-show="togglediv">Show (ng-show)</div>
</div>
CSS
body{
font-family: arial;
}
.item{
color: #fff;
padding: 20px;
background: #229EDC;
margin: 10px;
}
JavaScript
/* -------------------------------------------------------
* Filename: Angular ng-show vs ng-if
* Website: http://www.shanidkv.com
* Description: Shanidkv AngularJS blog
* Author: Muhammed Shanid
---------------------------------------------------------*/
var app = angular.module('angularjs-starter', []);
app.controller('MainCtrl', function($scope) {
$scope.togglediv = false;
});