Skip to content

Instantly share code, notes, and snippets.

@fen89
Created March 17, 2020 16:25
Show Gist options
  • Save fen89/0b886e22c19faa8751e01b0f559e546c to your computer and use it in GitHub Desktop.
Save fen89/0b886e22c19faa8751e01b0f559e546c to your computer and use it in GitHub Desktop.
Angular Invy print current selected component props (and observables) in browser console
current = ng.getComponent($0);
console.group(`${$0.localName} observables`);
observables = getObservables(current);
observables.forEach(({ key, value }) => value.subscribe(current => console.log(key, current)));
console.groupEnd();
console.group(`${$0.localName} props`);
props = getNonObservables(current);
props.forEach(({ key, value }) => console.log(key, value));
console.groupEnd();
function isObservable(value) {
return (value.hasOwnProperty('_isScalar') && value['_isScalar'] === false);
}
function getObservables(component) {
const observables = Object.keys(component)
.map(key => ({ key: key, value: component[key]}))
.filter(property => isObservable(property.value))
return observables;
}
function getNonObservables(component) {
const nonObservables = Object.keys(component)
.map(key => ({ key: key, value: component[key]}))
.filter(property => !isObservable(property.value))
return nonObservables;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment