Search code examples
angularjselementparent

How to get the ID of the parent of an element in AngularJs


In the code below:

   angular.element(element).parent()

How can I access the ID of the parent? When if I do this:

   console.log(angular.element(element).parent())

the console gives me below:

enter image description here


Solution

  • Use .attr()/.prop() method

    angular.element(element).parent().attr('id')