隔离范围元素上的角度动画
Angular animation on an isolated scope element
我有一个指令,它公开了notify
父作用域的单个函数。指令的其余部分需要保持私密。
angular.module('my-module')
.directive('notifier', function() {
return {
restrict: 'E',
replace : true,
template : '<div n-notify="notify">{{message}}</div>',
scope : {
message : '@',
nNotify : '='
},
link : function($scope, element, attrs) {
$scope.nNotify = function(message)
{
$scope.message = message;
element.addClass('notify-this');
};
}
}
})
.animate('.notify-this', function() {
return {
addClass : function(el, class, done) {
// Code here
},
removeClass : function(el, class, done) {
// Code here
}
}
});
当指令不在隔离范围内时,动画工作正常。当我隔离范围时,添加类时动画不适用。当使用javascript进行动画时,如何让动画在隔离范围内工作?
在隔离的作用域中,类需要与$animate
服务一起应用。使用 jQlite、jQuery 或 vanilla JS 添加类将不起作用。
.directive('notifier', ['$animate', function() {
return {
restrict: 'E',
replace : true,
template : '<div n-notify="notify">{{message}}</div>',
scope : {
message : '@',
nNotify : '='
},
link : function($scope, element, attrs) {
$scope.nNotify = function(message)
{
$scope.message = message;
$animate.addClass(el, 'notify-this');
};
}
}
}]);
相关文章:
- 如何设置html元素填充的动画
- 如何使用动画实现纸张推车
- 如何在生成下载文件时显示加载动画
- 剑道网格jQuery动画()问题
- EaseJS拖放;放下(动画CC)电影剪辑的鼠标坐标
- 正在全局范围中查找JavaScript函数
- jQuery Lazy加载动画滚动
- jquery动画可以通过编程链接吗
- Javascript将数学动画化
- 动画.CSS重播
- 如何通过数组更新角度子范围
- 制作一个不带HTML a标记但在动画播放完毕后指向其他页面的超链接
- 角度:将动画与范围更改相结合
- 隔离范围元素上的角度动画
- 请求动画帧范围更改为窗口
- 如何正确设置范围输入元素的动画
- 范围设置后启动svg动画-svg
- javascript如何在googleearth中设置kml文件的动画范围
- 汽车动画重置在一个特定的范围
- 在一个数值范围内进行动画