Skip to content

Commit 6118ec4

Browse files
committed
feat: loading spinner
1 parent 7f30a6e commit 6118ec4

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

src/app/items/items-list/items-list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ <h1>Items</h1>
44
<item-detail [item]='item'></item-detail>
55
</div>
66

7-
<loading-spinner></loading-spinner>
7+
<loading-spinner *ngIf="showSpinner"></loading-spinner>
88

99

1010

src/app/items/items-list/items-list.component.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,16 @@ import { FirebaseListObservable } from "angularfire2";
1010
})
1111
export class ItemsListComponent implements OnInit {
1212

13-
public items: FirebaseListObservable<Item[]>;
13+
items: FirebaseListObservable<Item[]>;
14+
15+
showSpinner: boolean = true;
16+
1417

1518
constructor(private itemSvc: ItemService) { }
1619

1720
ngOnInit() {
1821
this.items = this.itemSvc.getItemsList({limitToLast: 5})
19-
}
20-
21-
22-
addEmptyItem() {
23-
let item = new Item()
24-
this.itemSvc.createItem(item)
22+
this.items.subscribe(() => this.showSpinner = false)
2523
}
2624

2725
deleteItems() {

src/app/items/shared/item.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class ItemService {
1717
// Return an observable list with optional query
1818
// You will usually call this from OnInit in a component
1919
getItemsList(query={}): FirebaseListObservable<Item[]> {
20-
this.items = this.db.list(this.basePath, {
20+
this.items = this.db.list('/items', {
2121
query: query
2222
});
2323
return this.items

src/app/ui/loading-spinner/loading-spinner.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, OnInit, Input } from '@angular/core';
22

33
@Component({
44
selector: 'loading-spinner',
@@ -7,6 +7,7 @@ import { Component, OnInit } from '@angular/core';
77
})
88
export class LoadingSpinnerComponent implements OnInit {
99

10+
1011
constructor() { }
1112

1213
ngOnInit() {

src/app/uploads/uploads-list/uploads-list.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ <h3>File Uploads</h3>
44
<upload-detail [upload]='upload'></upload-detail>
55
</div>
66

7+
<loading-spinner *ngIf="showSpinner"></loading-spinner>
8+
79
<hr>
810

911
<upload-form></upload-form>

src/app/uploads/uploads-list/uploads-list.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ import { Upload } from '../shared/upload';
1111
export class UploadsListComponent implements OnInit {
1212

1313
uploads: FirebaseListObservable<Upload[]>;
14+
showSpinner: boolean = true;
1415

1516
constructor(private upSvc: UploadService) { }
1617

1718
ngOnInit() {
1819
this.uploads = this.upSvc.getUploads({limitToLast: 5})
20+
this.uploads.subscribe(() => this.showSpinner = false)
1921
}
2022

2123

0 commit comments

Comments
 (0)