Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70745

Alert popup data pushed to firebase

$
0
0

@RobertLow wrote:

Hi, I wanted to push the data keyed in from the popup box to firebase for future retrieve.

This is my code,

home.ts

import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';

import { allItem } from './../../models/all-item/all-item.interface';

toggleValue: boolean = false;

  allItemRef2$: FirebaseListObservable<allItem[]>

   this.allItemRef2$ = this.database.list('Quantity');

activatePopup(toggleValue: true) {
    let prompt = this.alertCtrl.create({
      title: 'Quantity',
      message: "Enter quantity",
      inputs: [
        {
          name: 'quantity',
          type: 'number'
        },
      ],
      buttons: [
        {
          text: 'Cancel',
          handler: data => {
            console.log('Cancel clicked');
          }
        },
        {
          text: 'Confirm',
          handler: data => {
            console.log('Saved clicked');
            console.log(JSON.stringify(data));
            console.log(data.quantity);
          }
        }
      ]
    });

    if (this.toggleValue === true) {
      prompt.present();
    }
    else {
    }

home.html

 <ion-toggle [disabled]='false' [(ngModel)]="toggleValue" (ionChange)="activatePopup(true)" style='zoom:0.8;'></ion-toggle>


all-item.interface.ts

export interface allItem {
    quantity?: number;
}

I have tried done this code in home.ts however, it output was quantity is undefined.

      this.allItemRef2$.push({
        quantity: Number(this.allItem.quantity)
      });

      //reset Allitem
      this.allItem = {} as allItem;

Thankyou in advance.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70745

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>