0

I save simple key in a variable in a component using angular 4, when the app closed every value will erased and i know it.

this is a simple sample :

export class LoginComponent implements OnInit {

  data : any;

  constructor() {
    this.data = "Hello";
  }

}

I just want to know is there a way using browser console to show value in this.data without console.log()?

DAIRAV
  • 723
  • 1
  • 9
  • 31
yozawiratama
  • 4,209
  • 12
  • 58
  • 106

1 Answers1

2

Yes you can.

Start by finding some HTML that belongs to your component in your page. Then, inspect it.

In Chrome, you will see a $0 besides it. That's a variable reference.

Now, go into your console and type

ng.probe($0).componentInstance

This will log you your whole component, with the variables that are in it. You can simply give it a reference

const myRef = ng.probe($0).componentInstance

Then delete your component as you want, and log it again from the console directly

console.log(myRef) // or shorthand
myRef