Skip to content

Commit 7db16e5

Browse files
committed
Show a loader
1 parent 23c9d36 commit 7db16e5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/app/app.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<a (click)="getEntries()">Get All Entries</a> | <a (click)="getEntries({include: 1})">Query Entries</a> | <a (click)="getEntry('651CQ8rLoIYCeY6G0QG22q', {include: 1})">Get entry</a>
2+
<div *ngIf="l">Loading...</div>
23
<pre>
34
{{r | json}}
45
</pre>

src/app/app.component.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,23 @@ import { ContentfulService } from './modules/contentful/contentful.service';
88
})
99
export class AppComponent {
1010
r: any;
11+
l = false;
1112

1213
constructor(private cs: ContentfulService) {}
1314

1415
getEntries(query?: any) {
15-
this.cs.getEntries(query).then(res => this.r = res);
16+
this.l = true;
17+
this.cs.getEntries(query).then(res => {
18+
this.r = res;
19+
this.l = false;
20+
});
1621
}
1722

1823
getEntry(id: string, query?: any) {
19-
this.cs.getEntry(id, query).then(res => this.r = res);
24+
this.l = true;
25+
this.cs.getEntry(id, query).then(res => {
26+
this.r = res;
27+
this.l = false;
28+
});
2029
}
2130
}

0 commit comments

Comments
 (0)