angular / batarang

AngularJS WebInspector Extension for Chrome
MIT License
2.43k stars 338 forks source link

Right click scope object to use "Store as global variable" feature from console #281

Closed tim545 closed 8 years ago

tim545 commented 8 years ago

I'm not sure if this is actually possible to put into an extension but it would nice to have. Copying the object to a global variable means you can run some simple tests against it in the console, just as bit of a shorthand if your debugging something.

SomeKittens commented 8 years ago

Whenever you select an element in the Elements pane, we set the global $scope to the scope of that variable, so that's a first step. Would be nice to just get whatever you're looking at directly though.

tim545 commented 8 years ago

Yeah ok I see that now... which actually works for purpose I wanted which is cool. But the feature I was wanting to replicate was something in the console when have done a console.log() from your code you can right click that log entry and select "store as global variable" (screen shot below) which then assigns it a variable name so you can do some simple manipulations on it there in the console. But of course as you said the $scope object will always be there! I just didn't notice it before.

screen shot 2015-11-20 at 1 46 42 pm

SomeKittens commented 8 years ago

Yep, and we'll see about adding that too! It's a good suggestion, we're a bit backlogged though.

tim545 commented 8 years ago

That's ok, if you could get it into a future release sometime that would be really cool!

ProLoser commented 8 years ago

@tim545 I think this is tricky because variables are always in context of scope. There's no reason you can't console log in your current ng codebase, but to figure out what scope data you want is complex and requires you to poke around the DOM. Once it's done, you can do window.x = $scope so it persists

stan-kondrat commented 8 years ago

@tim545 you can use "$scope" element tab:

tim545 commented 8 years ago

@ProLoser Sure no worries, I always only suggested it because I thought it would be a nice shortcut of sorts instead of logging from the code etc. but It's no big deal. I like the solutions you and @stan-kondrat have found anyway! thanks for those. If it's something that's too big to implement for a small feature I'd be happy with closing the issue, no point leaving it lying around

SomeKittens commented 8 years ago

Thanks, @stan-kondrat, didn't know about that one! Looks good enough to close. Thanks for bringing this up and having a great attitude, @tim545