Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call an angular 6 function from browser console?

Tags:

angular6

I want to call a function that is inside a component from the browser console. I want something like this but equivalent to angular 6.

Thank you in advance

like image 284
Kimy BF Avatar asked Jul 04 '18 01:07

Kimy BF


People also ask

How to call a function from console in Angular?

If this function is inside a closure, Then you can't call from the console. Otherwise, you just do functionName(); and hit return.

Can we call function in HTML in angular?

To invoke this function in the html document, we have to create a simple button and using the onclick event attribute (which is an event handler) along with it, we can call the function by clicking on the button.


1 Answers

Yes you can check by below method..

on your google chrome console, you can run below command

ng.probe($0).componentInstance.<name of function you want to run from component.ts file>

You can check the output.

Do let me know if you need further clarification.

Please check reference for better understanding.

like image 112
Flutterian Avatar answered Dec 16 '22 23:12

Flutterian