How to pass the parameter betwen component ionic 2 (data json) from the home page to the side menu

I need to pass the (members) parameter from the page Cheval.ts to page app.html forread the data

App/app.html

<ion-menu id="menu1" side="left" type="push" [content]="content">
  <ion-header>
    <ion-toolbar>
      <ion-title>aa</ion-title>
    </ion-toolbar>
  </ion-header>

  <ion-content>
    <ion-list>
      <button menuClose="menu1" ion-item *ngFor="let p of pages" >
        {{ p }}
      </button>
    </ion-list>
  </ion-content>

</ion-menu>
<ion-menu id="menu2" side="right" type="push" [content]="content">
  <ion-header>
    <ion-toolbar>
      <ion-title>search</ion-title>
    </ion-toolbar>
  </ion-header>

  <ion-content>
    <ion-list>
      <ion-label>Date</ion-label>
    <ion-select >
      <ion-option *ngFor="let m of cheval" value="nes">{{m.Cheval.nom}}</ion-option>
    </ion-select>
    </ion-list>
  </ion-content>
</ion-menu>


<!-- Disable swipe-to-go-back because it's poor UX to combine STGB with side menus -->
<ion-nav [root]="rootPage" #content ></ion-nav>

Page/Cheval.ts

@Component({
  selector: 'page-cheval',
  templateUrl: 'cheval.html'
})
export class ChevalPage {

   members;
  constructor(public navCtrl: NavController,public popoverCtrl: PopoverController, public navParams: NavParams,public data: ServiceProvider, public loadingCtrl:LoadingController  ,public menuCtrl: MenuController ) {
  this.getDados();
  this.initializeItems();
 getDados() {
      //retorno de Dados
    return  this.data.getData()
            .subscribe(
                  data=> {
                      this.members = data;
                      //console.log(data);
                      
                  },
                  err=> console.log(err)
                  
            );
      }
}

Why can’t the app component get the information from the same service provider that ChevalPage is getting it from? I also don’t understand why getDados() is returning a subscription.

To browse the list of horses in the Cheval.html pages

 <ion-row *ngFor="let member of members" (click)="View(member)" align-items-center>
        <ion-col width-30>
          {{member.CourseHasCheval.length}}
        </ion-col>
        <ion-col width-20>
          <strong *ngIf="member.Cheval.sexe==2">Mâle</strong>
          <strong *ngIf="member.Cheval.sexe==1">Femelle</strong>
        </ion-col>
        <ion-col width-25>
          {{member.Eleveur.prenom}}
        </ion-col>
        <ion-col width-25>
          {{member.Eleveur.nom_prenom}}
        </ion-col>

      </ion-row>

Sorry, but I’m not seeing how that relates to either of my questions.

getDados() A method is used to return thed data

Well, it doesn’t (and can’t) return any data. It is returning a subscription. My fundamental suggestion is that the app component should do the same serviceProvider.getData().subscribe(cheval => this.cheval = cheval) operation that ChevalPage is doing.

in app.component.ts ??

Yes. Inject the same service provider both in the app component and ChevalPage and get the information from there.

in the constructor ??

How about you try that and see how it goes.

not works

  • Don’t post screenshots of code.
  • Case matters.

Error with import serviceProviser in Constructor

@amine216 you should write ServiceProvider instead of serviceProvider