import { Component } from '@angular/core' ; import { IonicPage , NavController , NavParams } from 'ionic-angular' ; import { AngularFireDatabase , FirebaseListObservable } from 'angularfire2/database' ; import { ShoppingItem } from '../../models/shopping-item/shopping-item.interface' ; @ Component ( { selector : 'page-add-shopping' , templateUrl : 'add-shopping.html' , } ) export class AddShoppingPage { shoppingItem = { } as ShoppingItem ; shoppingItemRef$ : FirebaseListObservable < ShoppingItem [ ] > ; constructor ( public navCtrl , public navParams , private database ) { this . shoppingItemRef$ = this . database . list ( 'shopping-list' ) ; } addShoppingItem ( shoppingItem ) { this . shoppingItemRef$ . push ( { itemName : this . shoppingItem . itemName , itemNumber : Number ( this . shoppingItem . itemNumber ) } ) ; this . shoppingItem = { } as ShoppingItem ; this . navCtrl . pop ( ) ; } }