Why is $element available/injected in controller?

后端 未结 4 851
盖世英雄少女心
盖世英雄少女心 2020-12-25 11:30

In AngularJS, I\'ve noticed that a controller is injected with $element, which is a JQuery/JQLite wrapper of the element the controller is controlling. For exam

4条回答
  •  甜味超标
    2020-12-25 11:48

    Actually, $element is injected because you specified it as a dependency in the argument list. If you remove it from the list, it will not be injected.

    http://plnkr.co/edit/CPHGM1awvTvpXMcjxMKM?p=preview

    And as commented, there are case in which you need $element in the controller, although i can't think of any at the moment.

提交回复
热议问题