Problem with dictionaries
AngularFire doesn't play well with dictionaries containing only number-like keys.
http://embed.plnkr.co/KGbJan
How to reproduce the problems:
Case 1:
- Reset 1
- Remove the record which key is "bah"
- Result: AngularFire unbinds?
Case 2:
- Reset 2
- Add a record with key "01"
- Add a record with key "02"
- Add a record with key "03"
- Add a record with key "04"
- Result: AngularFire deletes the records ("01", "02", "03" and "04") after adding "04"
Case 3:
- Reset 2
- Add a record with key "1"
- Add a record with key "2"
- Add a record with key "3"
- Add a record with key "4"
- Result: AngularFire treats the variable as a simple array instead of a dictionary
This is unfortunately a characteristic of Firebase. Firebase doesn't store arrays, only objects. Objects with numeric keys that "look" like arrays are treated as such by the client. In all these cases, the type of the object switches between an array an object, thereby confusing the (key, value) in records statement.
Closing this issue, but if you have any suggestions on what the behavior should be in these cases, please so let us know!
Is there a workaround for this issue? I agree that it is generally useful but in some cases not only is it un-intuitive, it actually just plain doesn't work (i.e. the data can't even been accessed via a for loop)
This issue is over a year old and the library has been rewritten twice since then. Please upgrade to the latest version (currently 0.9.0), use the new $firebase.$asArray() method, and you won't have this issue.
I am using the latest version and experiencing this bug, I will throw together a test case and check back.
Yeah, please do get together a repro. Also, if you could open a new issue, it would be much appreciated.