大家。 我对角度没有经验,所以需要帮助。 我有一个指令:
app.directive('ngDirective', [ '$timeout', function ($timeout) {
return {
templateUrl: '../tpl/tpl.html',
restrict: 'E',
scope:{
item:'=',
},
link:function(scope, element, attrs) {
//some func here
scope.myFunction =function(item){
$(element).find('.myitem').css('-webkit-transform','scale(0.6)').animate({opacity:0},function(){
$timeout(function(){
var ListIndex = scope.$parent.$index;
scope.$parent.$parent.ItemsList.splice(ListIndex, 1);
scope.$parent.$parent.updateSomeStuff();
});
})
};
}
};
}]);
问题是scope.myFunction触发jQuery更改两次,首先在元素处,然后在列表中的兄弟处理;同时它只从列表中删除一个元素。如果我删除父范围功能-jQuery工作正常并触发一次。如果我删除jquery行-parent范围func工作完美,我需要如何正确组织这个? 我认为从列表中删除以某种方式绑定jquery再次运行,但我不了解该过程... 我错过了什么?