0

I want to show data from addData page to Dashboard page

I input data in page addData with code

saveData(){
this.storage.set(this.key, this.inputtext);}

And for test the input save i use code

 loadData(){
this.storage.get(this.key).then((val) => {
  console.log('Your ipaddress is', val);
});

in my addData page.html i have code

<ion-input position="floating" [(ngModel)]="inputtext" placeholder="IP 
Address"></ion-input>
<ion-button routerLink="/dashboard" (click)="saveData()">OK</ion-button>

How to show the data in Dasboard page.html with my input in addData page?

ShinAe
  • 1
  • 1
  • are you specifically wanting to use the device storage to accomplish this? because https://stackoverflow.com/questions/52187282/ionic-4-how-to-pass-data-between-pages-using-navctrl-or-router-service is generally how data is send between pages. – Juan Aug 26 '19 at 10:27
  • i follow the step but i don't know how to call the function in html – ShinAe Aug 27 '19 at 01:14

2 Answers2

0

If you use router navigation insted of routerlink. I hope it will helps you.

saveData(){
this.storage.set(this.key, this.inputtext);
this.storage.get('key').then((val) => {
    this.data = val;
    console.log('Your ipaddress is', val);
 })
this.router.navigate(['dashboard']);
}

<ion-input position="floating" [(ngModel)]="inputtext" 
placeholder="IP 
Address"></ion-input>
<span *ngIf="data">{{data}}</span>
<ion-button (click)="saveData()">OK</ion-button>
Pushprajsinh Chudasama
  • 7,772
  • 4
  • 20
  • 43
0

in your ts file

GetData()
 {
    this.storage.get('key').then(value=>
      {
        this.data=value;
        console.log("your ipadress is",val)

  )}

in Html file use string interpolation to output data something like this:

<span *ngIf="data> {{data}} </span>
Srinath gunnu
  • 162
  • 1
  • 12