-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make $-prefixed properties of $firebaseObject non-enumerable #579
Comments
Use angular.forEach() |
Ah, nice. Didn't realise that filtered out This issue still causes slight nuisance when I want to do a map, since there's no analogous |
Yep, I didn't mention it, but we do appreciate the feedback (at ng-conf and a bit distracted). I was just pondering what action item to take on this. |
For what it's worth, we've already done this for $$conf. If you are seeing $$conf, then lodash/underscore must be bypassing the hasOwnProperty() check? |
Double-checks... nope, I don't see There is one other point that might be worth considering here: if angular/angular.js#6266 were ever to get implemented, wouldn't it break most projects using current versions of AngularFire in a spectacular way? It might be worth chiming in there, and/or making these properties non-enumerable to make sure that such a change can't cause an incompatibility with AngularFire. |
Since |
A |
Example context: having a |
Unless we make the $ variables non-enumerable, presumably. Let me ponder that. But really, if it's a list of users, $firebaseArray() would be more appropriate. |
Decided not to take any action here. Making this properties non-enumerable will effectively make them harder to discover for those who don't like to read the docs and would rather poke around in the debugger. Since we expect collections to be handled as part of $firebaseArray, I've decided to punt on this and leave $id and $priority simple to iterate. angular.forEach() provides a nice simple workaround for avoiding them. |
@katowulf Is there any other way to get just the data from const obj = $firebaseObject(firebaseRef.child(…));
…
angular.forEach(obj, (val, key) => {
if (String(key).charAt(0) === '$') {
return;
}
…
}); |
To my knowledge it never has, but it does filter using It is not well documented, but there is |
@jamestalmage thanks a lot, |
Has this been fixed? Or does anyone have a workaround? |
Does @jamestalmage's suggestion above of using |
@jamestalmage Thank you, this helped me as well. |
Presently, the
$$conf
,$id
and$priority
properties of a$firebaseObject
are normal, enumerable properties. This is inconvenient if I want to loop over the object's properties with afor .. in
loop or something like LoDash's_.each()
method.Currently I work around this with code like
but this is ugly, and the ugliness is greater still in circumstances where what I'd really like to do is something like an
_.map
call.It would be more convenient if these properties were created with
Object.defineProperty
to be non-enumerable.Considerations:
$foo
properties non-enumerable (see what is currently the final post at ngRepeat: property names starting with "$" will not be rendered angular/angular.js#6266) but may or may not follow through on thisI advocate making the change, but you may see things differently.
The text was updated successfully, but these errors were encountered: