角NG-INIT通元件到范围 [英] Angular ng-init pass element to scope
本文介绍了角NG-INIT通元件到范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法让我的地方NG-init的当前绑定在当前元素?
Is there a way to get the current element where my ng-init is currently binded on?
例如:
<div ng-init="doSomething($element)"></div>
我相信,有一种方法,NG-点击,但我不能做到这一点使用NG-INIT是这样的:
I believe that there is a way for ng-click but I can't do this using ng-init like this:
<div ng-click="doSomething($event)"></div>
控制器:
$scope.doSomething = function(e){
var element = angular.element(e.srcElement);
}
我如何做到这一点与NG-INIT?
How do I do this with ng-init?
推荐答案
不要这么做。
作为@ $ C $遮打说,haddling在指令的DOM操作是一个更好的解决方案。
As @CodeHater said, haddling DOM manipulation in a directive is a better solution.
这篇关于角NG-INIT通元件到范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文