-
-
Save danielnv18/4bb1d77dc0860493d717692939b8e47e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ion-header> | |
<ion-navbar> | |
<ion-title>Homepage</ion-title> | |
</ion-navbar> | |
</ion-header> | |
<ion-content padding> | |
<ion-list> | |
<ion-item *ngFor="let item of items | async" (click)="selectItem(item)"> | |
<h2>{{item.name}}</h2> | |
</ion-item> | |
</ion-list> | |
</ion-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { IonicPage, NavController, NavParams, ActionSheetController } from 'ionic-angular'; | |
import { AngularFirestore, AngularFirestoreCollection } from 'angularfire2/firestore'; | |
import { Observable } from 'rxjs/Observable'; | |
import { Item } from '../../models/item/item.interface'; | |
@IonicPage() | |
@Component({ | |
selector: 'page-homepage', | |
templateUrl: 'homepage.html', | |
}) | |
export class HomePage { | |
private itemsCollection: AngularFirestoreCollection<Item>; | |
items: Observable<Item[]>; | |
constructor( | |
public navCtrl: NavController, | |
public navParams: NavParams, | |
private afs: AngularFirestore, | |
private actionSheetCtrl: ActionSheetController | |
) { | |
this.itemsCollection = afs.collection<Item>('items'); | |
this.items = this.itemsCollection.valueChanges(); | |
} | |
selectItem(item: Item) { | |
this.actionSheetCtrl.create({ | |
title: `${item.name}`, | |
"buttons": [ | |
{ | |
text: "Edit", | |
handler: () => { | |
// this.navCtrl.push('ItemEditPage',{ | |
// itemId: item.$key | |
// }); | |
} | |
}, | |
{ | |
text: "Delete", | |
role: "destructive", | |
handler: () => { | |
console.log(item); | |
//this.itemsCollection.doc().delete | |
} | |
}, | |
{ | |
text: "Cancel", | |
role: "cancel", | |
handler: () => { | |
} | |
} | |
] | |
}).present(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment