ng.probe($0).componentInstance
-- will give the reference to the instance.
Is there any way to access the directive instance from the console?
Directive instance doesn't differ from other providers in this respect, it can be retrieved from injector.
In order to retrieve provider instance, it is necessary to have provider token, which is directive class. Since application classes aren't exposed to global scope, debug element providerTokens
can be inspected.
Given the application is unminified and functions preserve their original names, directive (provider) token is retrieved like:
var FooDirective = ng.probe($0).providerTokens.find(token => token.name === 'FooDirective');
And directive (provider) instance is retrieved like:
ng.probe($0).injector.get(FooDirective);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With