AngularJS animate image on src change

前端 未结 8 2244
一整个雨季
一整个雨季 2020-12-30 09:26

I have an AnuglarJS app, where I load/change some images from a webservice...

Controller

.controller(\'PlayerCtrl\', function($scope, programService         


        
8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-30 10:18

    As christoph has mentioned, you should watch using $watch on the image source change. But first make sure you use the ng-src rather than the src for the image tag.

    
    
    $scope.$watch('program.image', function(newValue, oldValue) {
        if(newValue===oldValue) return;
        $('img#new').hide();
        $('img#new').fadeIn("slow", function() {});
    })
    

提交回复
热议问题