I have some element like :
<button ng-click="weirdFunction()">Pretty Button</button>
And function in controller :
$scope.weirdFunction = function(element) {
console.log(element);
}
in console log I want to receive this DOM element. I tried to do this in several ways:
<button ng-click="weirdFunction()" ng-model="button">Pretty Button</button>
$scope.weirdFunction = function() { console.log($scope.button); }
<button ng-click="weirdFunction(button)" ng-model="button">Pretty Button</button>
$scope.weirdFunction = function(elem) { console.log(elem); }
<button ng-click="weirdFunction($element)">Pretty Button</button>
$scope.weirdFunction = function(elem) { console.log(elem); }
But all attempts were failures. Where I'm wrong? How to get an element which clicked?
ng-click="weirdFunction($event.target)"
, first place why you need DOM there?previousElementSibling.style.display = 'inline-block'