firebase/angularFire — pull request #15 by thomasboyt (2013-04-14 18:31:34+00:00)
Title: Chat refactor & .add() bugfix

Two commits:

First, I refactored the chat example to use Angular directives rather than having the controller manipulate the DOM. This is more elegant and in tune with how Angular does DOM manipulation. It does increase the LOC significantly, but I think it's worth it for a more "real-world" example.

Second, while refactoring, I noticed that you had to pass a callback to `.add()`. Here was the old code:

```javascript
collection.add = function(item, cb) {
collectionRef.push(item, cb ? cb : null);
};
```

In theory, it looks like this was intended to allow an unset callback. However, `.push()` will try to call its second argument as a function, whether it's set to `null` or not, so you just ended up with an "object is not a function" error if you don't pass a callback to `.add()`.

I've changed this so it doesn't pass a second argument at all to `.push()` if no callback argument is specified.