Skip to content

Instantly share code, notes, and snippets.

@JasonStoltz
Last active August 29, 2015 14:15
Show Gist options
  • Save JasonStoltz/26b3673f9644212518dd to your computer and use it in GitHub Desktop.
Save JasonStoltz/26b3673f9644212518dd to your computer and use it in GitHub Desktop.
Debugging Angular expressions in chrome console

Inline expressions sort of suck because they're hard to debug... if you end up with a really long, unweildy filter, here's a way to debug them in the browser console.

ex. of lengthy expression:

<tr id="element" ng-repeat="resource in alertingEnvironment.environment.database_services.resources | map:'servers.resources' | flatten | unique:'id' | concat: alertingEnvironment.environment.servers.resources">
</tr>
function $eval(expr) {
  return angular.element("#element").scope().$eval(expr);
}
$eval("resource in alertingEnvironment.environment.database_services.resources | map:'servers.resources' | flatten | unique:'id' | concat: alertingEnvironment.environment.servers.resources");

Tip: In chrome, you can simply click on the element you want and select "Copy CSS Path".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment