M
M
Maxim Ivanov2016-07-11 16:04:32
Angular
Maxim Ivanov, 2016-07-11 16:04:32

Why can't I use onclick in angularjs method?

<li ng-click="archive($index)"><a> test </a>

app.controller('ClickController', ['$scope', function($scope, $el) { 


  $scope.archive = function($index){
 
   // мне нужна имитация клика на другой элемент
  // но возникает ошибка
 //  $(".switch .lever").click()

// вот это событие срабатывает, но выдает ошибку в консоль
document.querySelector(".switch .lever").click();

/* angular.element('.switch .lever').triggerHandler('click');  не срабатывает*/

  }

}]);

If I move $(".switch .lever").click() outside of the function, everything works, what should I do, do I need it to work inside this function?
fb46e462fc5f4af58e86ed8e13c3231a.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nicholas, 2016-07-11
@splincodewd

If you need to do this, you've made a mistake somewhere in the architecture.

A
Alexander Filippenko, 2016-07-11
@alexfilus

jQuery(".switch .lever").click();
Tried?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question