This repository has been archived on 2020-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
angularjs-batarang/devtoolsBackground.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2014-08-06 21:46:54 +00:00
var panels = chrome.devtools.panels;
// The function below is executed in the context of the inspected page.
var getPanelContents = function () {
if (window.angular && $0) {
//TODO: can we move this scope export into updateElementProperties
var scope = window.angular.element($0).scope();
// Export $scope to the console
window.$scope = scope;
return (function (scope) {
var panelContents = {
__private__: {}
};
for (prop in scope) {
if (scope.hasOwnProperty(prop)) {
if (prop.substr(0, 2) === '$$') {
panelContents.__private__[prop] = scope[prop];
} else {
panelContents[prop] = scope[prop];
}
}
}
return panelContents;
}(scope));
} else {
return {};
}
};
panels.elements.createSidebarPane(
"AngularJS Properties",
function (sidebar) {
panels.elements.onSelectionChanged.addListener(function updateElementProperties() {
sidebar.setExpression("(" + getPanelContents.toString() + ")()");
});
});
2014-08-06 21:46:54 +00:00
var angularPanel = panels.create(
"AngularJS",
"img/angular.png",
"panel/app.html"
2014-08-06 21:46:54 +00:00
);