Is there any way to access Angular2 specific component specific data in console, for debugging purpose?
Like Angular1 has capability to access its components value i
Using global scope variable.(any browser)
index.html
on your component file
declare var test: any;
After ngOnInit() of that component file
For example
ngOnInit() {
test = this;
}
Now we can access every variables and function of that component including services(imported on that component).
If you want to prevent accessing test for let's say production, you can conditionally give access to test like:
constructor(private _configService: ConfigService) {
}
ngOnInit() {
if(_configService.prod) {
test = this;
}
}
Here _configService means the instance of service used by all components and services.
So variable would be set like:
export class ConfigService {
prod = false;
}