jQuery find() method not working in AngularJS directive

前端 未结 7 989
说谎
说谎 2021-01-31 14:26

I am having trouble with angularjs directives finding child DOM elements with the injected angular element.

For example I have a directive like so:



        
7条回答
  •  走了就别回头了
    2021-01-31 15:19

    You can easily solve that in 2 steps:

    1- Reach the child element using querySelector like that: var target = element[0].querySelector('tbody tr:first-child td')

    2- Transform it to an angular.element object again by doing: var targetElement = angular.element(target)

    You will then have access to all expected methods on the targetElement variable.

提交回复
热议问题