|
11 | 11 | * [`$bindTo(scope, varName)`](#bindtoscope-varname) |
12 | 12 | * [`$watch(callback, context)`](#watchcallback-context) |
13 | 13 | * [`$destroy()`](#destroy) |
| 14 | + * [`$resolved`](#resolved) |
14 | 15 | * [`$firebaseArray`](#firebasearray) |
15 | 16 | * [`$add(newData)`](#addnewdata) |
16 | 17 | * [`$remove(recordOrIndex)`](#removerecordorindex) |
|
22 | 23 | * [`$ref()`](#ref-1) |
23 | 24 | * [`$watch(cb[, context])`](#watchcb-context) |
24 | 25 | * [`$destroy()`](#destroy-1) |
| 26 | + * [`$resolved`](#resolved-1) |
25 | 27 | * [`$firebaseAuth`](#firebaseauth) |
26 | 28 | * Authentication |
27 | 29 | * [`$signInWithCustomToken(authToken)`](#signinwithcustomtokenauthtoken) |
@@ -174,8 +176,8 @@ obj.$save().then(function(ref) { |
174 | 176 |
|
175 | 177 | ### $loaded() |
176 | 178 |
|
177 | | -Returns a promise which is resolved when the initial object data has been downloaded from the database. |
178 | | -The promise resolves to the `$firebaseObject` itself. |
| 179 | +Returns a promise which is resolved asynchronously when the initial object data has been downloaded |
| 180 | +from the database. The promise resolves to the `$firebaseObject` itself. |
179 | 181 |
|
180 | 182 | ```js |
181 | 183 | var obj = $firebaseObject(ref); |
@@ -288,6 +290,32 @@ unwatch(); |
288 | 290 | Calling this method cancels event listeners and frees memory used by this object (deletes the |
289 | 291 | local data). Changes are no longer synchronized to or from the database. |
290 | 292 |
|
| 293 | +### $resolved |
| 294 | + |
| 295 | +Attribute which represents the loaded state for this object. Its value will be `true` if the initial |
| 296 | +object data has been downloaded from the database; otherwise, its value will be `false`. This |
| 297 | +attribute is complementary to the `$loaded()` method. If the `$loaded()` promise is completed |
| 298 | +(either with success or rejection), then `$resolved` will be `true`. `$resolved` will be |
| 299 | +`false` before that. |
| 300 | + |
| 301 | +Knowing if the object has been resolved is useful to conditionally show certain parts of your view: |
| 302 | + |
| 303 | +```js |
| 304 | +$scope.obj = $firebaseObject(ref); |
| 305 | +``` |
| 306 | + |
| 307 | +```html |
| 308 | +<!-- Loading state --> |
| 309 | +<div ng-if="!obj.$resolved"> |
| 310 | + ... |
| 311 | +</div> |
| 312 | + |
| 313 | +<!-- Loaded state --> |
| 314 | +<div ng-if="obj.$resolved"> |
| 315 | + ... |
| 316 | +</div> |
| 317 | +``` |
| 318 | + |
291 | 319 |
|
292 | 320 | ## $firebaseArray |
293 | 321 |
|
@@ -461,8 +489,8 @@ list.$indexFor("zulu"); // -1 |
461 | 489 |
|
462 | 490 | ### $loaded() |
463 | 491 |
|
464 | | -Returns a promise which is resolved when the initial array data has been downloaded from the |
465 | | -database. The promise resolves to the `$firebaseArray`. |
| 492 | +Returns a promise which is resolved asynchronously when the initial array data has been downloaded |
| 493 | +from the database. The promise resolves to the `$firebaseArray`. |
466 | 494 |
|
467 | 495 | ```js |
468 | 496 | var list = $firebaseArray(ref); |
@@ -547,6 +575,32 @@ function compare(a, b) { |
547 | 575 | Stop listening for events and free memory used by this array (empties the local copy). |
548 | 576 | Changes are no longer synchronized to or from the database. |
549 | 577 |
|
| 578 | +### $resolved |
| 579 | + |
| 580 | +Attribute which represents the loaded state for this array. Its value will be `true` if the initial |
| 581 | +array data has been downloaded from the database; otherwise, its value will be `false`. This |
| 582 | +attribute is complementary to the `$loaded()` method. If the `$loaded()` promise is completed |
| 583 | +(either with success or rejection), then `$resolved` will be `true`. `$resolved` will be |
| 584 | +`false` before that. |
| 585 | + |
| 586 | +Knowing if the array has been resolved is useful to conditionally show certain parts of your view: |
| 587 | + |
| 588 | +```js |
| 589 | +$scope.list = $firebaseArray(ref); |
| 590 | +``` |
| 591 | + |
| 592 | +```html |
| 593 | +<!-- Loading state --> |
| 594 | +<div ng-if="!list.$resolved"> |
| 595 | + ... |
| 596 | +</div> |
| 597 | + |
| 598 | +<!-- Loaded state --> |
| 599 | +<div ng-if="list.$resolved"> |
| 600 | + ... |
| 601 | +</div> |
| 602 | +``` |
| 603 | + |
550 | 604 |
|
551 | 605 | ## $firebaseAuth |
552 | 606 |
|
|
0 commit comments