Permalink
Browse files

Step 13.2: Define options and use it in the subscription

  • Loading branch information...
1 parent 569474e commit 0f871e66392bf21dd5eb4a38f797fe7bf00ddf24 @kamilkisiela kamilkisiela committed with DAB0mB Sep 23, 2016
Showing with 21 additions and 2 deletions.
  1. +21 −2 client/imports/app/parties/parties-list.component.ts
@@ -8,17 +8,36 @@ import { Party } from '../../../../both/models/party.model';
import template from './parties-list.component.html';
+interface Pagination {
+ limit: number;
+ skip: number;
+}
+
+interface Options extends Pagination {
+ [key: string]: any
+}
+
@Component({
selector: 'parties-list',
template
})
export class PartiesListComponent implements OnInit, OnDestroy {
parties: Observable<Party[]>;
partiesSub: Subscription;
+ pageSize: number = 10;
+ curPage: number = 1;
+ nameOrder: number = 1;
ngOnInit() {
- this.parties = Parties.find({}).zone();
- this.partiesSub = MeteorObservable.subscribe('parties').subscribe();
+ const options: Options = {
+ limit: this.pageSize,
+ skip: (this.curPage - 1) * this.pageSize,
+ sort: { name: this.nameOrder }
+ };
+
+ this.partiesSub = MeteorObservable.subscribe('parties', options).subscribe(() => {
+ this.parties = Parties.find({}).zone();
+ });
}
removeParty(party: Party): void {

0 comments on commit 0f871e6

Please sign in to comment.