search

Home  >  Q&A  >  body text

angular.js - Can angular applications directly obtain elements in html and pass them into functions as parameters?

Angular application, how can I use jquery directly in html to obtain elements and pass them into functions as parameters?

<button ng-click="vm.getButton($(this))"></button>
var ctrl = this;
ctrl.getButton = (elem) => {
    console.log(elem);
};
The

in the this function directly points to the current scope, and the element cannot be obtained. Is there any solution?

过去多啦不再A梦过去多啦不再A梦2754 days ago487

reply all(1)I'll reply

  • 世界只因有你

    世界只因有你2017-05-15 17:05:04

    Currently, the requirements are implemented through the following methods

    <button ng-click="vm.getButton($event)"></button>
    var ctrl = this;
    ctrl.getButton = ($event) => {
        console.log($($event.currentTarget));
    };

    reply
    0
  • Cancelreply