Chapter 3: Creating leave and concurrent animations with ng-view
HTML
<script src="https://code.angularjs.org/1.3.2/angular.min.js"></script>
<script src="https://code.angularjs.org/1.3.2/angular-animate.min.js"></script>
<script src="https://code.angularjs.org/1.3.2/angular-route.min.js"></script>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<div ng-app="myApp">
<ng-view class="animate-container"></ng-view>
<div class="link-container">
<a href="#/foo">Foo</a>
<a href="#/bar">Bar</a>
</div>
<script type="text/ng-template" id="foo.html">
<div>
<span>Foo</span>
</div>
</script>
<script type="text/ng-template" id="bar.html">
<div>
<span>Bar</span>
</div>
</script>
</div>
CSS
.link-container {
position:absolute;
top:320px;
}
.animate-container {
position:absolute;
}
.animate-container div {
width:300px;
text-align:center;
line-height:300px;
border:1px solid black;
}
.animate-container.ng-enter {
/* final value is the transition delay */
transition:all 0.5s 0.5s;
}
.animate-container.ng-leave {
transition:all 0.5s;
}
.animate-container.ng-enter,
.animate-container.ng-leave.ng-leave-active {
top:-300px;
}
.animate-container.ng-leave,
.animate-container.ng-enter.ng-enter-active {
top:0px;
}
JavaScript
angular.module('myApp', ['ngAnimate', 'ngRoute'])
.config(function ($routeProvider) {
$routeProvider
.when('/bar', {
templateUrl: 'bar.html'
})
.otherwise({
templateUrl: 'foo.html'
});
});