Guest User

Untitled

a guest
May 27th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. <ion-content>
  2.  
  3. <ion-list *ngFor="let i of informations | async" >
  4. <ion-item (click)="OpenDetails(i.key)">{{i.title}}</ion-item>
  5. </ion-list>
  6.  
  7. </ion-content>
  8.  
  9. import { Component } from '@angular/core';
  10. import { NavController, NavParams } from 'ionic-angular';
  11. import { AngularFireDatabase } from 'angularfire2/database';
  12. import { InformationdetailsPage } from '../informationdetails/informationdetails';
  13. import { map } from 'rxjs/operators';
  14.  
  15.  
  16. @Component({
  17. selector: 'page-list',
  18. templateUrl: 'list.html'
  19. })
  20. export class ListPage {
  21.  
  22. informationslist:any;
  23. informations:any;
  24.  
  25. constructor(public navCtrl: NavController, public navParams: NavParams,
  26. private afDB: AngularFireDatabase) {
  27.  
  28.  
  29.  
  30. this.informationslist = afDB.list('information');
  31. this.informations = this.informationslist.snapshotChanges().pipe(
  32. map(changes =>
  33. changes.map(c => ({ key: c.payload.key, ...c.payload.val() }))
  34. )
  35. );
  36.  
  37. }
  38.  
  39. OpenDetails(key:any){
  40. this.navCtrl.push(InformationdetailsPage, key);
  41. }
  42.  
  43.  
  44.  
  45. }
  46.  
  47. this.informations = this.informationslist.snapshotChanges().pipe(
  48. **map**(changes =>
  49. changes.map(c => ({ key: c.payload.key, ...c.payload.val() }))
  50. )
  51. );
  52.  
  53. import { map } from 'rxjs/operators';
  54.  
  55. this.informations = this.informationslist.snapshotChanges().pipe(
  56. map(changes =>
  57. changes.**map**(c => ({ key: c.payload.key, ...c.payload.val() }))
  58. )
  59. );
Add Comment
Please, Sign In to add comment