AngularJS — Animations
Setup Animations
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular-animate.min.js"></script>
var app = angular.module('myApp', ['ngAnimate']);
CSS Classes
| Class | When Added |
|---|---|
| ng-enter | Element enters DOM |
| ng-leave | Element leaves DOM |
| ng-move | Element moves in DOM |
| ng-hide | Element hidden |
| ng-show | Element shown |
CSS Animations
.ng-enter {
opacity: 0;
transition: opacity 0.5s;
}
.ng-enter-active {
opacity: 1;
}
.ng-leave {
opacity: 1;
transition: opacity 0.5s;
}
.ng-leave-active {
opacity: 0;
}
Show/Hide Animations
div {
transition: all 0.5s ease;
}
div.ng-hide {
opacity: 0;
transform: scale(0.8);
}
Repeat Animations
li.ng-enter {
opacity: 0;
transform: translateY(-20px);
transition: all 0.3s;
}
li.ng-enter-active {
opacity: 1;
transform: translateY(0);
}
Mini Practice
- Enable ngAnimate
- Create enter/leave animations
- Animate show/hide
- Add transition effects
Up Next
Continue with DOM — AngularJS DOM manipulation.
Related Topics
Frequently Asked Questions about Animations
What is Animations in AngularJS?
Animations is a fundamental concept in AngularJS. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Animations?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Animations.
Why is Animations important in AngularJS?
Animations is essential for AngularJS development. Understanding this concept will help you write better code and solve real-world problems more effectively.