Guest User

Untitled

a guest
Feb 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <ion-item-sliding *ngFor="let list of list" >
  2. <ion-item>
  3. <p>An item:
  4. <strong>{{list.list1}}</strong>
  5. </p>
  6. <p>Oooooh is this important:
  7. <strong>{{list.list2}}</strong>
  8. </p>
  9. <p>Another item:
  10. <strong>{{list.list3}}</strong>
  11. </p>
  12. </ion-item>
  13.  
  14. <ion-item-options side="left">
  15. <button ion-button color="danger" (click)="deleteList(list.id)"> // this should be id not key
  16. <ion-icon name="md-trash">Delete</ion-icon>
  17. </button>
  18. </ion-item-options>
  19. </ion-item-sliding>
  20.  
  21. import { EventProvider } from '../../providers/event/event';
  22. import { User } from 'firebase/app'; // import user from firebase;
  23. import * as firebase from 'firebase/app';
  24.  
  25. @IonicPage()
  26.  
  27. export class ListPage {
  28. /* public list: Array<any>; */
  29. lists = [];
  30. authenticatedUser: User; //declare variable authenticatedUser as type User
  31. constructor(
  32. public navCtrl: NavController,
  33. public eventProvider: EventProvider
  34. ) { firebase.auth().onAuthStateChanged(user => {
  35. if (user) {
  36. this.authenticatedUser = user;
  37. }
  38. });
  39. }
  40.  
  41. deleteList(key) {
  42. firebase
  43. .database()
  44. .ref(`/userProfile/${this.authenticatedUser.uid}/List/${key}`).remove()
  45. }
  46.  
  47. ionViewDidLoad() {
  48. this.eventProvider.getlist().on('value', listSnapshot => {
  49. this.lists = [];
  50. listSnapshot.forEach(snap => {
  51. this.lists.push({
  52. id: snap.key,
  53. list1: snap.val()
  54. });
  55. return false; // why are you returning false dont use it.
  56. });
  57. });
  58. }
  59.  
  60. }
Add Comment
Please, Sign In to add comment