AngularJS – get element attributes values
Since you are sending the target element to your function, you could do this to get the id: function doStuff(item){ var id = item.attributes[‘data-id’].value; // 345 }
Since you are sending the target element to your function, you could do this to get the id: function doStuff(item){ var id = item.attributes[‘data-id’].value; // 345 }
Essentially, and as-noted by @kevin-b: // find(‘#id’) angular.element(document.querySelector(‘#id’)) //find(‘.classname’), assumes you already have the starting elem to search from angular.element(elem.querySelector(‘.classname’)) Note: If you’re looking to do this from your controllers you may want to have a look at the “Using Controllers Correctly” section in the developers guide and refactor your presentation logic into appropriate directives … Read more