Skip to content

Instantly share code, notes, and snippets.

@anonymoussc
Created August 2, 2015 14:51
Show Gist options
  • Save anonymoussc/2ac60b409914dd831204 to your computer and use it in GitHub Desktop.
Save anonymoussc/2ac60b409914dd831204 to your computer and use it in GitHub Desktop.
AngularJS ngHide animation

##AngularJS ngHide animation

The ngShow directive uses the same convention; the only difference is that each directive has the opposite behavior for the model value. When the model is true , ngShow removes the ng-hide class and ngHide adds the ng-hide class

<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title>AngularJS ngHide sample</title>
<link href="http://ajax.aspnetcdn.com/ajax/bootstrap/3.2.0/css/bootstrap.css" rel="stylesheet"/>
<link href="style.css" rel="stylesheet"/>
</head>
<body>
<div>
<div>
<button ng-click="disabled = !disabled">Toggle ngHide animation</button>
<div ng-hide="disabled" class="ngHideSample bg-success">
This element has the ng-hide directive.
</div>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular-animate.min.js"></script>
<script src="script.js"></script>
</body>
</html>
var app = angular.module('myApp', ['ngAnimate']);
/* ngHide animation */
.ngHideSample {
padding : 10px;
margin : 5px;
}
.ngHideSample.ng-hide-add {
-webkit-transition : all linear 0.3s;
-moz-transition : all linear 0.3s;
-ms-transition : all linear 0.3s;
-o-transition : all linear 0.3s;
opacity : 1;
}
.ngHideSample.ng-hide-add-active {
opacity : 0;
}
.ngHideSample.ng-hide-remove {
-webkit-transition : all linear 0.3s;
-moz-transition : all linear 0.3s;
-ms-transition : all linear 0.3s;
-o-transition : all linear 0.3s;
opacity : 0;
}
.ngHideSample.ng-hide-remove-active {
opacity : 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment