shindesharad71 / Ionic-Firebase-Shopping-List

A Shopping List Hybrid Mobile Application For Understanding Concepts of Ionic 3 and Firebase.
0 stars 0 forks source link

Get Error using this code. #1

Closed parveen-chhillar closed 6 years ago

parveen-chhillar commented 6 years ago

import { Component } from '@angular/core'; import { IonicPage, NavController, NavParams } from 'ionic-angular'; import { AngularFireDatabase,AngularFireList } from 'angularfire2/database'; import { ShoppingItem } from '../../models/shopping-item/shopping-item.interface'; import { Subscription } from 'rxjs/Subscription'; import {AddShoppingPage} from '../../pages/add-shopping/add-shopping'; @Component({ selector: 'page-edit-shopping-item', templateUrl: 'edit-shopping-item.html', }) export class EditShoppingItemPage { shoppingItemRef$: any; shoppingItem = {} as ShoppingItem; shoppingItemSubscription: Subscription; constructor(public navCtrl: NavController, public navParams: NavParams, private database: AngularFireDatabase ) { const shoppingItemId = this.navParams.get('shoppingItemid'); console.log('shoppingItemId:', shoppingItemId); this.shoppingItemRef$ = this.database.object(shopping-list/${shoppingItemId}); this.shoppingItemRef$.subscribe(shoppingItem => this.shoppingItem = shoppingItem);

}

editShoppingItem(shoppingItem: ShoppingItem){
  this.shoppingItemRef$.update(shoppingItem);
  this.navCtrl.pop();
}

ionViewDidLoad() { console.log('ionViewDidLoad EditShoppingItemPage'); }

}

This is my code. And i get this error while i click on Edit button:

Error: Uncaught (in promise): TypeError: this.shoppingItemRef$.subscribe is not a function TypeError: this.shoppingItemRef$.subscribe is not a function at new EditShoppingItemPage (http://localhost:8100/build/main.js:230:31) at createClass (http://localhost:8100/build/vendor.js:12859:20) at createDirectiveInstance (http://localhost:8100/build/vendor.js:12700:37) at createViewNodes (http://localhost:8100/build/vendor.js:14158:53) at createRootView (http://localhost:8100/build/vendor.js:14047:5) at callWithDebugContext (http://localhost:8100/build/vendor.js:15472:42) at Object.debugCreateRootView [as createRootView] (http://localhost:8100/build/vendor.js:14755:12) at ComponentFactory_.create (http://localhost:8100/build/vendor.js:11652:46) at ComponentFactoryBoundToModule.create (http://localhost:8100/build/vendor.js:4404:29) at NavControllerBase._viewInit (http://localhost:8100/build/vendor.js:52167:44) at c (http://localhost:8100/build/polyfills.js:3:19752) at Object.reject (http://localhost:8100/build/polyfills.js:3:19174) at NavControllerBase._fireError (http://localhost:8100/build/vendor.js:51949:16) at NavControllerBase._failed (http://localhost:8100/build/vendor.js:51942:14) at http://localhost:8100/build/vendor.js:51989:59 at t.invoke (http://localhost:8100/build/polyfills.js:3:14976) at Object.onInvoke (http://localhost:8100/build/vendor.js:5134:33) at t.invoke (http://localhost:8100/build/polyfills.js:3:14916) at r.run (http://localhost:8100/build/polyfills.js:3:10143) at http://localhost:8100/build/polyfills.js:3:20242

shindesharad71 commented 6 years ago

Sorry, @ParveenChhillar this project is not maintained, the errors might due to the new version of Angular and Ionic.