Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Chrome Dev tools help figure out Angular component name?

Assuming that I have the Angular source code for the application, how can I use Chrome Developer tools to figure out the name of a specific Angular component?

For example, let's say the application makes use of a popup dialog box and I want to find the source code for the dialog box. Can Chrome Developer tools help me figure out then name of the component?

So far I have been drilling down the elements tree in Chrome Dev tools and when I think I have the element for the dialog box I search the angular code for the HTML. However, I often get false matches and it is time consuming. I was wondering if there was a better way I might not be familiar with.

like image 693
webworm Avatar asked Nov 27 '18 19:11

webworm


1 Answers

Use Augury:

You can use Augury. It's a Chrome and Firefox Extension Managed by the folks at Rangle.

Once you've installed it, just open Chrome Dev Tools(assuming you're using Chrome), and it will be visible as one of the Tabs in the tools.

You can simply select a Component from the Web page and it is going to accurately mark the Component that you were on as of then.

enter image description here

Use ng.probe($0).componentInstance

You can select a component using the Element Selector from the Elements Tab. And then go to the Console Tab, and type in:

ng.probe($0).componentInstance

This is going to give you the Component Instance of the recently selected Component along with its name and then you can look for it accordingly. Something like this:

enter image description here

NOTE: There methods would only work in DEV mode.

like image 82
SiddAjmera Avatar answered Oct 16 '22 01:10

SiddAjmera