Ionic page redirection with firebase


#1

I am using ionic 3.

And I installed angular fire 2 .

My root page is the dashboard.

Below my UpdateProfile section.

Here is my form (updateprofile.html)

 <form [formGroup]="updateprofile"  novalidate >
                <div>
                    <img (click)="upload()" *ngIf="ImageURL" class="image2" [src]="ImageURL">
                    <img  *ngIf="File" class="image2" [src]="File" imageViewer/>
                    <img (click)="upload()" *ngIf="!File && !ImageURL " class="image2" src="http://vignette1.wikia.nocookie.net/dragonage/images/f/f4/User-info.png/revision/latest?cb=20100528043005" imageViewer/>
                </div>
                    <h6 (click)="upload()">Edit Photo</h6>
                    <p (click)="view()"><ion-icon name="eye"></ion-icon>&nbsp;&nbsp;View Profile</p>
                <ion-list>
                    <ion-item >
                       <ion-label floating >First Name</ion-label>
                        <ion-icon name="ios-person-outline" item-left></ion-icon>
                        <ion-input type="text" name="FirstName"  formControlName="FIRST_NAME"></ion-input>
                    </ion-item>

                    <ion-item >
                        <ion-label floating >Last Name</ion-label>
                        <ion-icon name="ios-person-outline" item-left></ion-icon>
                        <ion-input type="text" name="FirstName" formControlName="LAST_NAME"></ion-input>
                    </ion-item>

                    <ion-item >
                        <ion-label floating >Address</ion-label>
                         <ion-icon name="ios-home-outline" item-left></ion-icon>
                        <ion-input type="text" name="FirstName" formControlName="ADDRESS"></ion-input>
                    </ion-item>

                    <ion-item>
                        <ion-label floating>Email</ion-label>
                        <ion-icon name="ios-mail-outline" item-left></ion-icon>
                        <ion-input type="email" disabled="true" name="Email" formControlName="EMAIL"></ion-input>
                    </ion-item>

                    <ion-item>
                       <ion-label floating>Mobile 1</ion-label>
                       <ion-icon name="ios-call-outline" item-left></ion-icon>
                       <ion-input type="text" name="Username" formControlName="MOBILE1"></ion-input>
                    </ion-item>

                    <ion-item>
                        <ion-label floating>Mobile 2</ion-label>
                        <ion-icon name="ios-call-outline" item-left></ion-icon>
                        <ion-input type="text" name="Username" formControlName="MOBILE2"></ion-input>
                    </ion-item>

                    <ion-item>
                        <ion-label>Gender</ion-label>
                        <ion-select formControlName="GENDER">
                            <ion-option value="Female">Female</ion-option>
                            <ion-option value="Male">Male</ion-option>
                        </ion-select>
                    </ion-item>
                </ion-list>

                     <div class="btn" (click)="submit($event)">
                        <button class="update" ion-button >Update</button>
                     </div>
            </form>

Here is my submit function(updateprofile.ts)

submit(event: Event){
    event.preventDefault();
    if(this.ImageURL != undefined)
    {
       var fileName = 'sample-' + new Date().getTime() + '.jpg';
       let uploadTask = this.firebase.storage().ref('profile/' + fileName);
        console.log(this.updateprofile.value);
         uploadTask.put(this.getURL).then((snapshot) => {
         this.updateprofile.controls['FILE'].setValue(snapshot.downloadURL); 
         var val=this.af.database.list('/users');
         val.update(this.key,this.updateprofile.value);
         this.platform.ready().then(() => {
            window.plugins.toast.show("Profile updated success", "short",'bottom',1000);
       });

     });
    }
   if(this.ImageURL === undefined)
   {
      console.log(this.updateprofile.value);
     var val=this.af.database.list('/users');
     val.update(this.key,this.updateprofile.value);
     this.platform.ready().then(() => {
              window.plugins.toast.show("Profile update success", "short",'bottom',1000);

         });
    // this.editvalue=true;
   }
  }

I didn’t write any code in page redirection.But Page is automatically redirected to the Root page.

If I disabled the firebase update function.The page does not redirect to rootpage.

How can i fix this issue.

I have no idea.

Kindly advice me,

Thanks.