【发布时间】:2016-03-30 06:17:03
【问题描述】:
我有一个自定义的角度指令,所以当你点击元素时它会向下移动: angular.module('plunker', [])
.controller('AnimateCtlr', function(){
})
.directive('clickToAnimate', function(){
var linker = function(scope, element, attrs) {
element.bind('click', function(){
console.log('moving');
console.log( $( this).text() );
$(this).animate({top: '+=150'});
});
};
return {
restrict: 'AE',
replace: false,
scope: {
direction : '@'
},
link: linker
};
});
所有检测点击事件的console.log 工作,但问题是,div 根本没有移动。这里有什么问题?
Plunker 在这里:http://plnkr.co/edit/j1OMiZFrar71P742dY6W?p=preview
【问题讨论】:
-
动画效果很好,你的css不正确
标签: javascript jquery angularjs angular-directive