I want to insert a jquery animation when a $scope property changes. When $scope.currentImage in this case changes, I want to detect it an animate so the image gets a nice transition.
I THINK the way to do this is with the $watch expression but I wanted to run it by everyone to see if I am on the right track. I would appreciate any feedback on my approach. Thanks!
HTML Code
<img ng-src="{{currentImage.image}}" alt="{{currentImage.description}}">
JavaScript Code
// Cache so reference is only looked up once
$scope.$albumImage = $('#albumImage img');
// This function is designed to add an animation to when the image changes
$scope.$watch('currentImage', function() {
// hide the current image
$scope.$albumImage.hide();
// when the new image loads - fade it in
$scope.$albumImage.load(function() {
$scope.$albumImage.fadeIn();
});
});
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/h-0c8gwpisEJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.