Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When does one use $asArray vs $asObject in Angularfire?

It seems like there are many situations where one could choose whether to use $asArray or $asObject, in the same situation. You could get away with using either.

I'm a bit of a code/js beginner, but when should one use $asArray vs. $asObject?

like image 699
Brian Smith Avatar asked Mar 29 '26 21:03

Brian Smith


1 Answers

The latest version of angularfire 1.0.0 uses new $firebaseArray and $firebaseObject services that replace $asArray and $asObject when accessing collections or objects.

If you are using the latest version, you should convert $asObject and $asArray to the new services.

var arr = $firebase(new Firebase(URL)).$asArray;
var obj = $firebase(new Firebase(URL)).$asObject;

becomes

var arr = $firebaseArray(new Firebase(URL));
var obj = $firebaseObject(new Firebase(URL));

Additional information is available at AngularFire Documentation

like image 72
Saeed D. Avatar answered Apr 02 '26 10:04

Saeed D.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!