Skip to content

Instantly share code, notes, and snippets.

@bvaughn
bvaughn / gist:012fb525e6c819fdc9bf
Last active May 23, 2016 15:01
Debugging Angular bindings

This afternoon I encountered a race condition in an Angular app I'm working on. Essentially my controller was pushing some values to an Array on its scope and something (I wasn't sure what) was asynchronously overriding the Array's contents. The Array was being used by a custom directive- written by someone else- as well as an ngModel and it wasn't clear who was making the change.

I ended up trying something I had not done before and it worked well enough that I thought I'd post it here in case it helped anyone else.

First I enabled The "Async" option in Chrome's "Sources > Call Stack" panel.

Next I set a breakpoint in my controller where I was modifying the Array. When I hit that breakpoint, I ran the following code in my console:

Object.observe(this.theArray, function(changes) {
@bennadel
bennadel / isolate-scope-directive.htm
Created June 16, 2014 12:15
Using Isolate Scope In Directives In AngularJS
<!doctype html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>
Using Isolate Scope In Directives In AngularJS
</title>
<link rel="stylesheet" type="text/css" href="./demo.css"></link>