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

Runtime Error Object(...) is not a function

$
0
0

@FK2193 wrote:

when i save data in the database it will give me an error :TypeError: Object(…) is not a function
here is my code,
schedule.ts

  saveRem() {

    /*Saving Reminder */
    let notificationTime = new Date();
    //Assigning time and checking whether today or tommorrow
    if (this.times < notificationTime.getTime() || (notificationTime.getTime() == this.times)) {
      notificationTime.setTime(this.times+24);
    } else {
      notificationTime.setTime(this.times);
    }


    let reminder = {
      id: notificationTime.getMilliseconds(),
       data: this.med,
      time: notificationTime,
      frequency: this.takingadose,
      duration: this.mySDate,
      durationend: this.myEDate,
      repeatt: this.Repetition

    };
    this.reminders.push(reminder);
    this.database.savepatientData(new reminderdata(this.id,this.Repetition,this.mySDate,this.myEDate,
      this.times,this.med,this.Dose,this.takingadose,this.Routine,"pending"))
      .subscribe((rem:any)=>{
        if(rem!=null){
         this.reminders.push(new reminderdata(this.id,this.Repetition,this.mySDate,this.myEDate,
           this.times,this.med,this.Dose,this.takingadose,this.Routine,"pending"));
           this.med='';
           this.takingadose='';
           this.times='';
           this.Routine='';
           this.Dose='';
           this.Repetition='';
           this.mySDate='';
           this.myEDate='';

        }
        if(rem.responseList.length>0)
          this.navCtrl.push(ReminderPage,rem.responseList[0])
          else
            this.navCtrl.push(ReminderPage, {})
        },
        function (error) {
        }
      );
    // this.database.savepatientData(new SaveSchedule(this.data,this.meddata,this.myendDate,this.repeatition,
    //   this.times,this.takingadose,this.mystartDate,this.routine,this.id,this.dose,'pending')).subscribe(
    //
    // )
    /*Saving in system notification */
    let notification = {
      id: notificationTime.getMilliseconds(),
      title: 'Medicine Reminder',
      text: 'Its time to take ' + this.med + ' medicine :)',
      at: notificationTime,
      led: 'FF0000',
      every: this.takingadose
    };


    /*Saving in System Notifictation*/
    this.localNotifications.schedule(notification);
    let msg = 'Reminder for medicine ' + this.med + ' has been set.';

    //Creating Alert
    let alert = this.altertCtrl.create({
      title: 'Reminder Set',
      message: msg,
      buttons: [{
        text: 'Ok',
        handler: () => {
          // user has clicked the alert button
          // begin the alert's dismiss transition
          let navTransition = alert.dismiss();

          // start some async method

          // once the async operation has completed
          // then run the next nav transition after the
          // first transition has finished animating out

          navTransition.then(() => {
            this.navCtrl.pop();
          });
          return false;
        }
      }]
    });
    alert.present();

  }

sehdule.html

<!--
  Generated template for the MySchedulePage page.

  See http://ionicframework.com/docs/components/#navigation for more info on
  Ionic pages and navigation.
-->
<ion-header>

  <ion-navbar>
    <ion-title>MySchedule</ion-title>
  </ion-navbar>

</ion-header>

<ion-content>
  <button ion-button end (click)="saveRem()">
    <ion-icon name="checkmark-circle"></ion-icon>
  </button>

  <div>
    <h5>Parameters passed:</h5>

    <pre style="background-color: #f8f8f8">selections: [
      {{med}}
      ]</pre>

  </div>
  <ion-navbar>
    <ion-label> Please state the number of times per day that schedule repeat</ion-label>
  </ion-navbar>
  <ion-item>
    <ion-select [(ngModel)]="takingadose">
      <ion-option value="Once a day">Once a day</ion-option>
      <ion-option value="twice a day">twice a day</ion-option>
      <ion-option value="three times a day">three times a day</ion-option>
      <ion-option value="four times a day">four times a day</ion-option>
    </ion-select>
  </ion-item>

  <ion-navbar>
    <h3>Time and Dose</h3>
  </ion-navbar>
  <ion-item>
    <ion-label>Time and Dose</ion-label>
    <ion-datetime displayFormat="h:mm A" pickerFormat="h mm A" (ionChange)="timeChange($event)" [(ngModel)]="time" ></ion-datetime>

    <ion-select [(ngModel)]="Routine">

      <ion-option value="B">Breakfast</ion-option>
      <ion-option value="L">Lunch</ion-option>
      <ion-option value="D">Dinner</ion-option>
      <ion-option value="N" (click)="ForNewRoutine()">Create a new one</ion-option>
    </ion-select>

    <ion-navbar>
      <ion-label>Now,link each itntake to yourroutine and state the dosage for each of them</ion-label>
    </ion-navbar>

    <ion-select [(ngModel)]="Dose">
      <ion-option value="1">1.0 </ion-option>
      <ion-option value="2">2.0 </ion-option>
      <ion-option value="3">3.0 </ion-option>
      <ion-option value="4">4.0 </ion-option>
      <ion-option value="5">5.0 </ion-option>
      </ion-select>

  </ion-item>
  <ion-navbar color="#16dbb5">
    <ion-label>State the schedule repetition, if it repeat everyday you don't have to do anything. </ion-label>
  </ion-navbar>

  <ion-item (click)="toggleweedays()" *ngIf="!weekdaysIsEnabled">
   <ion-select [(ngModel)]="Repetition">
    <ion-option value="1">EveryDay</ion-option>
    <ion-option value="2" >Some week Day </ion-option>
    <ion-option value="3">Intervel</ion-option>
  </ion-select>

</ion-item>
  <ion-item click)="toggleweedays()" *ngIf="weekdaysIsEnabled">
    <ion-select [(ngModel)]="selectedDay" multiple="true" >
      <ion-option [value]="day" *ngFor="let day of daysOfWeek">{{ day }}</ion-option>
    </ion-select>
  </ion-item>
  <ion-navbar color="#16dbb5">
    <ion-label>Duration </ion-label>
  </ion-navbar>

  <ion-item>
    <ion-label>Start Date</ion-label>
    <ion-datetime displayFormat="MM/DD/YYYY" [(ngModel)]="mySDate"></ion-datetime>
  </ion-item>
<ion-item>
  <ion-label>End Date</ion-label>
  <ion-datetime displayFormat="MM/DD/YYYY" [(ngModel)]="myEDate"></ion-datetime>
</ion-item>

</ion-content>

reminderdata.ts

export class reminderdata {
  constructor(public id:number,
              public times: any,
              public takingadose: any,
              public Dose:any,
              public Routine: any,
              public  mySDate: any,
              public myEDate: any,
              public Repetition: any,
              public med:any,
              public Status:string){}
}```

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70440

Trending Articles



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