angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

ng-mouseover call all functions inside it

Open buihoanghai opened this issue 12 years ago • 5 comments

I have problem with ng-mouseover. It alway call all functions inside it. You can see in link: http://plnkr.co/edit/vPhMGwjgXQZzh5WFmv8q?p=preview

buihoanghai avatar Jun 10 '14 03:06 buihoanghai

HI, this is actually working as expected. mouseover -> digest -> interpolated stuff gets re-evaluated.

caitp avatar Jun 10 '14 03:06 caitp

But I just want call function only in ng-mouseover. How can I do that?

buihoanghai avatar Jun 10 '14 03:06 buihoanghai

Please read the contributing guidelines; these types of questions are ill-suited for GitHub. Thanks!

btford avatar Jun 10 '14 03:06 btford

@buihoanghai at the risk of invoking the wrath of Brian for answering a question on GitHub (I joke), you'll want to make sure that you don't cause a $digest. In particular, this would mean writing your own event handler directive which doesn't $digest. You can see how these are implemented in https://github.com/angular/angular.js/blob/master/src/ng/directive/ngEventDirs.js#L39-L59 --- The difference would be that you wouldn't use $scope.$apply(), but just $scope.$eval() instead

Other alternative solutions include using the new one-time binding syntax for your function calls in the template, if appropriate, or just using jQuery or native DOM apis for listening to DOM events from a directive or controller (be careful if you do this from a controller though, it's not really a great idea).

caitp avatar Jun 10 '14 03:06 caitp

I'm sorry about that. I'll find other forum for post question :).

buihoanghai avatar Jun 10 '14 03:06 buihoanghai