我希望有一个指令,通知用户数据已经更改(例如,改变bg颜色、抖动、滑动等)。简单的示例如下所示:
html:
<change watch="heartbeat">{{heartbeat}}</change>指令:
angular.module('module').directive('change', function($timeout) {
return {
restrict: 'E',
link: function(scope, element, attrs) {
scope.$watch(attrs.watch, function(value) {
element.addClass("changed");
$timeout(function() {
element.removeClass("changed");
}, 600);
});
}
}
});如何更改上述指令,使其使用ngAnimate功能?我一直在查看$animator服务,但我想不出如何将它安装到上述模型中。
发布于 2013-05-12 13:52:56
我相信这是不可能的。
ngAnimate指令目前只支持5种预定义类型的动画触发事件(v1.1.4):
上面的每一种操作都与特定的DOM操作操作结合在一起,而您希望实现的功能并不适合这5种类型中的任何一种,因此,在支持自定义动画事件之前,可能不会这样做。
更多的解释可以在这里找到:http://gsklee.im/post/50254705713/nganimate-your-angularjs-apps-with-css3-and-jquery
https://stackoverflow.com/questions/16327188
复制相似问题