Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 角度动画ng src更改_Angularjs_Css_Jquery Animate - Fatal编程技术网

Angularjs 角度动画ng src更改

Angularjs 角度动画ng src更改,angularjs,css,jquery-animate,Angularjs,Css,Jquery Animate,我在angular中有指令,它只是改变图像,我想在img改变时设置动画。但是我不知道怎么做。我的指示是: 'user strict'; angular.module('app') .directive('card', function ($timeout) { return { restrict: 'E', replace: true, template: '<img class="animat

我在angular中有指令,它只是改变图像,我想在img改变时设置动画。但是我不知道怎么做。我的指示是:

'user strict';
angular.module('app')
    .directive('card', function ($timeout) {
        return {
            restrict: 'E',
            replace: true,
            template: '<img class="animated {{anim}}" ng-src="./img/cards/{{cardid}}.png"/>',
            scope: {
                cardid: '@'
            },
            link: function (scope, elm, attrs) {
                scope.$watch('cardid', function (value) {
                    scope.anim = 'cardAnim';
                    $timeout(function () {
                        scope.anim = '';
                    }, 1000);
                });
            }
        };
    });
“用户严格”;
角度。模块('app')
.指令('card',函数($timeout){
返回{
限制:'E',
替换:正确,
模板:“”,
范围:{
卡迪德:“@”
},
链接:功能(范围、elm、属性){
范围:$watch('cardd',函数(值){
scope.anim='cardAnim';
$timeout(函数(){
scope.anim='';
}, 1000);
});
}
};
});

我百分之百肯定我的班级。卡达尼工作正常。因为当我通过浏览器手动添加这个类时,一切都很正常。我还看到这个类被添加到元素中,但什么也没有发生:(

“我如何在我自己的指令中使用动画?自定义指令中的动画也可以通过将$animate直接注入指令并在需要时调用它来建立。”?(页末)谢谢你的评论,我认为我最大的问题是我不知道如何将它与ng src一起使用。我可以使用ng if、ng show等,但在图像切换时不能使用ng src。你确定它在更改时支持ng src指令吗?我没有,也没有找到任何有效的解决方案。但必须有任何方法如何制作。