This is my first project working with Angular and i have some troubles with ng-animate. I did a couple of tutorials and in the tutorials i got everything working fine. Now i'm using Angular for a project and i just can't get ng-animate to work properly. The classes such as "ng-enter" and "ng-leave" are not added to the different elements.
I've compared all kinds of working scripts with mine but just can't find out what i am doing wrong.
My header:
<link rel="stylesheet" href="css/app.css">
<script src="js/libraries/jquery-2.1.1.min.js"></script>
<script src="js/libraries/angular.js"></script>
<script src="js/libraries/angular-animate.js"></script>
<script src="js/libraries/angular-resource.js"></script>
<script src="js/libraries/angular-route.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
My HTML:
<div class="view-container">
<div ng-view class="{{pageclass}} view-frame"></div>
</div>
My app.js
'use strict';
/* App Module */
var engineShowcaseApp = angular.module('engineShowcaseApp', [
'ngRoute',
'ngAnimate',
'engineShowcaseController',
'engineShowcaseServices'
]);
engineShowcaseApp.config(['$routeProvider',
function ($routeProvider) {
$routeProvider.
when('/', {
templateUrl: 'partials/main.html',
controller: 'MainCtrl'
}).
when('/chapters/:chapterID', {
templateUrl: 'partials/chapter.html',
controller: 'ChapterCtrl'
});
} ]);
My controllers.js:
'use strict';
/* Controllers */
var engineShowcaseController = angular.module('engineShowcaseController', []);
engineShowcaseController.controller('MainCtrl', function ($scope, Main) {
$scope.pageclass = "page-home";
$scope.hotspots = Main.query();
});
engineShowcaseController.controller('ChapterCtrl', function ($scope, $routeParams, Main) {
$scope.pageclass = "page-chapter";
$scope.chapter = Main.get({ chapterID: $routeParams.chapterID });
});
The HTML of the first/main pagina:
<div
ng-repeat="hotspot in hotspots"
class="hotspot hotspot-{{hotspot.id}}"
data-nextup="chapter-{{hotspot.id}}"
data-startframe="{{hotspot.startFrame}}"
data-endframe="{{hotspot.endFrame}}">
<a href="#/chapters/{{hotspot.chapterID}}">
{{hotspot.label}}
</a>
</div>
If i'm correct the div's with the class 'hotspot' should receive the 'ng-enter' and 'ng-leave' classes... but somehow they don't.
Could anyone help me out with this? What am i doing wrong? Many thanks!!
Couple of things you should pay checkout:
ng-leave.ng-leave-active
and ng-enter.ng-enter-active
, take place. You can read more on this in the article.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With