You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is often very useful to be able to control the scope/context that repl statements will be evaluated in. For instance when developing an angular controller you probably want to have access to your dependency injected variables. There doesn't seem to be an official way to do that so I thought I'd share a hack that seems to work.
Place the line: skewer.globalEval = function(expression) {return eval(expression);}
where you want your context, kind of like a debugger; statement. For instance:
What's going on here is you've changed the indirect eval in globalEval into a direct eval. That's an interesting hack. It may be worth formally encoding this as a mode of operation in Skewer.
The consequence is that you won't be able to make any more global definitions (though that won't matter much in an Angular app) and you'll suffer some degraded performance (direct eval causes deoptimization).
It is often very useful to be able to control the scope/context that repl statements will be evaluated in. For instance when developing an angular controller you probably want to have access to your dependency injected variables. There doesn't seem to be an official way to do that so I thought I'd share a hack that seems to work.
Place the line:
skewer.globalEval = function(expression) {return eval(expression);}
where you want your context, kind of like a
debugger;
statement. For instance:Now from the prompt you can easily access your $scope variables and such
js> alert($scope.someVar);
The text was updated successfully, but these errors were encountered: