При нажатии на кнопку ответа на другой странице? - PullRequest
0 голосов
/ 21 мая 2019

Я новичок в ionic, и при интеграции данных с API это была сложная задача, я хочу нажать на любую кнопку и выбрать любой смайлик и хочу представить эти данные вместо кнопки, которая была выбрана.

API интегрирован

home.ts page
  async showReactions(ev:any){

    console.log("you have clicked the button");
      const reactions = await this.popoverCtrl.create({
      component:ReactionComponent,
      event:ev,
      cssClass: 'contact-popover',
      backdropDismiss: false,
      showBackdrop:true,
      componentProps: {viewtype : this.viewtype}
    });

    reactions.onDidDismiss().then((dataReturned)=>{
      if (dataReturned!==null){
        this.dataReturned=dataReturned.data;
        console.log(dataReturned);
      }
      console.log('button is dismissed');      
    });
   return await reactions.present( );
  }
home.html
          <ion-button (click)="showReactions($event)"  >    
                            <div>Like</div>
                            <div *ngIf="dataReturned"> 
                                <img  src="{{dataReturned.post_excerpt}}" />
                            </div>
          </ion-button>
reaction.ts
  like(r)
  {
    let data =r;
    console.log("you have reacted");
    this.popCtrl.dismiss(data)
  } 
reaction.html
 <div (click)="like(r)" *ngFor="let r of reactions" >
<img src="{{r.post_excerpt}}"> 
...