You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
angularjs-batarang/js/services/appModel.js

45 lines
1.0 KiB
JavaScript

// Service for running code in the context of the application being debugged
panelApp.factory('appModel', function (chromeExtension, appContext) {
var _scopeCache = {},
_rootScopeCache = [];
// clear cache on page refresh
appContext.watchRefresh(function () {
_scopeCache = {};
_rootScopeCache = [];
});
return {
getRootScopes: function (callback) {
chromeExtension.eval(function (window) {
if (!window.__ngDebug) {
return;
}
return window.__ngDebug.getRootScopeIds();
},
function (data) {
if (data) {
_rootScopeCache = data;
}
callback(_rootScopeCache);
});
},
getModelTree: function (id, callback) {
if (!id) {
return;
}
chromeExtension.eval(function (window, args) {
return window.__ngDebug.getScopeTree(args.id);
}, {id: id}, function (tree) {
if (tree) {
_scopeCache[id] = tree;
}
callback(_scopeCache[id]);
});
}
};
});