Switching one icon button switches all icon buttons in my share post The 2019 Stack Overflow Developer Survey Results Are InIonic button showing 'ion-button' is not a known elementHow to implement Back button functionality in ionic 4?Ionic v4 back button queryparamsSwitching one icon button switches all icon buttons in my componentHow can I add suffix icon to Ionic 4 inputIonic 4 clearInput icon colorHow to use global or shared styles between components in ionic 4?ionic 4 loss of session using href and switching back to appTrigger ion-input focus when ion-icon clickedUnable to have icons in top of text in Ionic 4 ion-sliding-options

Will it cause any balance problems to have PCs level up and gain the benefits of a long rest mid-fight?

Can there be female White Walkers?

How did passengers keep warm on sail ships?

What is the motivation for a law requiring 2 parties to consent for recording a conversation

Slides for 30 min~1 hr Skype tenure track application interview

How come people say “Would of”?

Are turbopumps lubricated?

Is it okay to consider publishing in my first year of PhD?

Does HR tell a hiring manager about salary negotiations?

How much of the clove should I use when using big garlic heads?

Can we generate random numbers using irrational numbers like π and e?

APIPA and LAN Broadcast Domain

What is the meaning of Triage in Cybersec world?

Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?

How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?

Worn-tile Scrabble

What's the name of these plastic connectors

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

For what reasons would an animal species NOT cross a *horizontal* land bridge?

Did any laptop computers have a built-in 5 1/4 inch floppy drive?

Likelihood that a superbug or lethal virus could come from a landfill

Are there any other methods to apply to solving simultaneous equations?

Is Cinnamon a desktop environment or a window manager? (Or both?)

Why “相同意思的词” is called “同义词” instead of "同意词"?



Switching one icon button switches all icon buttons in my share post



The 2019 Stack Overflow Developer Survey Results Are InIonic button showing 'ion-button' is not a known elementHow to implement Back button functionality in ionic 4?Ionic v4 back button queryparamsSwitching one icon button switches all icon buttons in my componentHow can I add suffix icon to Ionic 4 inputIonic 4 clearInput icon colorHow to use global or shared styles between components in ionic 4?ionic 4 loss of session using href and switching back to appTrigger ion-input focus when ion-icon clickedUnable to have icons in top of text in Ionic 4 ion-sliding-options



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am making ionic project in my project i want to add double tab likes button .My proble is when tap on image then show likes icon for all post .I want to show only likes post icon .How can resolve this please help me below are my code which is used for likes icon..



tab1.page.html



 <ion-header>
<ion-toolbar color="secondary">

<ion-title style="border: 1px solid #ccc" (click)="scrollToTop()">Pictagram</ion-title>
</ion-toolbar>
</ion-header>

<ion-content cache-view="false">
<ion-refresher slot="fixed" (ionRefresh)="doRefresh($event)">
<ion-refresher-content
pullingIcon="arrow-dropdown"
pullingText="Pull to refresh"
refreshingSpinner="circles"
refreshingText="Refreshing...">
</ion-refresher-content>
</ion-refresher>

<hr no-margin no-padding>
<div (swipe)="swipePage($event)">

<!-- Cards -->
<ion-card no-padding padding-bottom no-margin class="card" *ngFor="let getImage of getImages3">

<ion-row>
<ion-col col-10>
<ion-item>
<ion-avatar item-left>
<img *ngIf="getImage.sex == 'male'" src="http://localhost:8000/files/getImage.image ">
<img *ngIf="getImage.sex == 'female'" src="http://localhost:8000/files/getImage.image ">
</ion-avatar>

<b style="width: 222px;display: -webkit-box;padding-left: 11px;">getImage.name</b>

</ion-item>
</ion-col>
<ion-col col-2>

</ion-col>
</ion-row>

<div>
<img src="http://localhost:8000/files/getImage.image " (click)="tapPhotoLike(getImage.id)">
</div>


<p no-margin no-padding>
<button clear ion-button icon-only class="like-btn">
<ion-icon no-padding [name]="like_btn.icon_name" color=" like_btn.color " class="icon-space"></ion-icon>
</button>
</p>

<ion-card-content class="padding">
<p class="like-content">
<ion-icon class="color" name="heart" ></ion-icon> getcounts likes
</p>
<p><b>getImage.title</b>getImage.info</p>

<ion-note style="font-size: 12px">
getImage.created_at

</ion-note>
</ion-card-content>

</ion-card>

</div>
</ion-content>


In tab1.page.ts file i am manage the icon please help me how to show icon only for liked post. how to set id please help me...



tab1.page.ts



import Component, OnInit from '@angular/core';
import UserService from '../user.service';
import User from '../user';
import first from 'rxjs/operators';
import Storage from '@ionic/storage';
import ToastController from '@ionic/angular';
import LoadingController from '@ionic/angular';
@Component(
selector: 'app-tab1',
templateUrl: 'tab1.page.html',
styleUrls: ['tab1.page.scss']
)

export class Tab1Page implements OnInit

getImages: User[] = [];
getImages2: User[] = [];
getImages3;
getcounts;
countLikes
counts
unlikes
public like_btn =
color: 'danger',
icon_name: 'heart-empty'
;

public tap: number = 0;

constructor(private userService: UserService,
public toastController: ToastController,
private storage: Storage,
public loadingController: LoadingController)



doRefresh(event)
this.userPost();
setTimeout(() =>
event.target.complete();
, 2000);


ngOnInit()
this.userPost();
this.getCountOfLikes();


async userPost()
const loading = await this.loadingController.create(
message: 'Please wait...',
spinner: 'crescent',
duration: 2000
);
await loading.present();
this.userService.getUserPost().pipe(first()).subscribe(getImages =>
this.getImages3 = getImages;
//console.log(this.getImages3);
loading.dismiss();
);


likeButton()
const detail_id = this.userService.getCurrentIdpostId();
if (this.like_btn.icon_name === 'heart-empty')
this.like_btn.icon_name = 'heart';
this.like_btn.color = 'danger';

this.storage.get('userId').then((val) =>
if (val)
this.userService.userPostLikes(val, detail_id).pipe(first()).subscribe(
async data =>
//console.log(data);
if (data['status'] === 'you have already liked this post')
const toast = await this.toastController.create(
message: 'you have already liked this post',
duration: 2000
);
toast.present();

this.getCountOfLikes();


);

);


else
this.like_btn.icon_name = 'heart-empty';
this.like_btn.color = 'danger';
this.unlikePost();
this.getCountOfLikes();



tapPhotoLike($detail_id)

this.userService.setCurrentIdpostId($detail_id);
this.tap++;
setTimeout(() =>
if (this.tap == 1)
this.tap = 0;
//alert('Single Tap');
if (this.tap > 1)
this.tap = 0;

this.likeButton();
//alert('Double Tap');

, 250);

ionViewWillEnter()
this.userPost();
this.getCountOfLikes();


getCountOfLikes()

this.userService.getCountId().pipe(first()).subscribe(likes =>
this.counts = likes;

for (var k in this.counts)

var i = this.counts[k].detail_id;


this.userService.getUserPostlikes(i).pipe(first()).subscribe(getlikes =>
this.getcounts = getlikes;
);
);


unlikePost()
let detail_id = this.userService.getCurrentIdpostId();
this.storage.get('userId').then((val) =>
if (val)
this.userService.unLikes(val, detail_id).subscribe(async dislikes =>
this.unlikes = dislikes;
)

);












share|improve this question






























    0















    I am making ionic project in my project i want to add double tab likes button .My proble is when tap on image then show likes icon for all post .I want to show only likes post icon .How can resolve this please help me below are my code which is used for likes icon..



    tab1.page.html



     <ion-header>
    <ion-toolbar color="secondary">

    <ion-title style="border: 1px solid #ccc" (click)="scrollToTop()">Pictagram</ion-title>
    </ion-toolbar>
    </ion-header>

    <ion-content cache-view="false">
    <ion-refresher slot="fixed" (ionRefresh)="doRefresh($event)">
    <ion-refresher-content
    pullingIcon="arrow-dropdown"
    pullingText="Pull to refresh"
    refreshingSpinner="circles"
    refreshingText="Refreshing...">
    </ion-refresher-content>
    </ion-refresher>

    <hr no-margin no-padding>
    <div (swipe)="swipePage($event)">

    <!-- Cards -->
    <ion-card no-padding padding-bottom no-margin class="card" *ngFor="let getImage of getImages3">

    <ion-row>
    <ion-col col-10>
    <ion-item>
    <ion-avatar item-left>
    <img *ngIf="getImage.sex == 'male'" src="http://localhost:8000/files/getImage.image ">
    <img *ngIf="getImage.sex == 'female'" src="http://localhost:8000/files/getImage.image ">
    </ion-avatar>

    <b style="width: 222px;display: -webkit-box;padding-left: 11px;">getImage.name</b>

    </ion-item>
    </ion-col>
    <ion-col col-2>

    </ion-col>
    </ion-row>

    <div>
    <img src="http://localhost:8000/files/getImage.image " (click)="tapPhotoLike(getImage.id)">
    </div>


    <p no-margin no-padding>
    <button clear ion-button icon-only class="like-btn">
    <ion-icon no-padding [name]="like_btn.icon_name" color=" like_btn.color " class="icon-space"></ion-icon>
    </button>
    </p>

    <ion-card-content class="padding">
    <p class="like-content">
    <ion-icon class="color" name="heart" ></ion-icon> getcounts likes
    </p>
    <p><b>getImage.title</b>getImage.info</p>

    <ion-note style="font-size: 12px">
    getImage.created_at

    </ion-note>
    </ion-card-content>

    </ion-card>

    </div>
    </ion-content>


    In tab1.page.ts file i am manage the icon please help me how to show icon only for liked post. how to set id please help me...



    tab1.page.ts



    import Component, OnInit from '@angular/core';
    import UserService from '../user.service';
    import User from '../user';
    import first from 'rxjs/operators';
    import Storage from '@ionic/storage';
    import ToastController from '@ionic/angular';
    import LoadingController from '@ionic/angular';
    @Component(
    selector: 'app-tab1',
    templateUrl: 'tab1.page.html',
    styleUrls: ['tab1.page.scss']
    )

    export class Tab1Page implements OnInit

    getImages: User[] = [];
    getImages2: User[] = [];
    getImages3;
    getcounts;
    countLikes
    counts
    unlikes
    public like_btn =
    color: 'danger',
    icon_name: 'heart-empty'
    ;

    public tap: number = 0;

    constructor(private userService: UserService,
    public toastController: ToastController,
    private storage: Storage,
    public loadingController: LoadingController)



    doRefresh(event)
    this.userPost();
    setTimeout(() =>
    event.target.complete();
    , 2000);


    ngOnInit()
    this.userPost();
    this.getCountOfLikes();


    async userPost()
    const loading = await this.loadingController.create(
    message: 'Please wait...',
    spinner: 'crescent',
    duration: 2000
    );
    await loading.present();
    this.userService.getUserPost().pipe(first()).subscribe(getImages =>
    this.getImages3 = getImages;
    //console.log(this.getImages3);
    loading.dismiss();
    );


    likeButton()
    const detail_id = this.userService.getCurrentIdpostId();
    if (this.like_btn.icon_name === 'heart-empty')
    this.like_btn.icon_name = 'heart';
    this.like_btn.color = 'danger';

    this.storage.get('userId').then((val) =>
    if (val)
    this.userService.userPostLikes(val, detail_id).pipe(first()).subscribe(
    async data =>
    //console.log(data);
    if (data['status'] === 'you have already liked this post')
    const toast = await this.toastController.create(
    message: 'you have already liked this post',
    duration: 2000
    );
    toast.present();

    this.getCountOfLikes();


    );

    );


    else
    this.like_btn.icon_name = 'heart-empty';
    this.like_btn.color = 'danger';
    this.unlikePost();
    this.getCountOfLikes();



    tapPhotoLike($detail_id)

    this.userService.setCurrentIdpostId($detail_id);
    this.tap++;
    setTimeout(() =>
    if (this.tap == 1)
    this.tap = 0;
    //alert('Single Tap');
    if (this.tap > 1)
    this.tap = 0;

    this.likeButton();
    //alert('Double Tap');

    , 250);

    ionViewWillEnter()
    this.userPost();
    this.getCountOfLikes();


    getCountOfLikes()

    this.userService.getCountId().pipe(first()).subscribe(likes =>
    this.counts = likes;

    for (var k in this.counts)

    var i = this.counts[k].detail_id;


    this.userService.getUserPostlikes(i).pipe(first()).subscribe(getlikes =>
    this.getcounts = getlikes;
    );
    );


    unlikePost()
    let detail_id = this.userService.getCurrentIdpostId();
    this.storage.get('userId').then((val) =>
    if (val)
    this.userService.unLikes(val, detail_id).subscribe(async dislikes =>
    this.unlikes = dislikes;
    )

    );












    share|improve this question


























      0












      0








      0








      I am making ionic project in my project i want to add double tab likes button .My proble is when tap on image then show likes icon for all post .I want to show only likes post icon .How can resolve this please help me below are my code which is used for likes icon..



      tab1.page.html



       <ion-header>
      <ion-toolbar color="secondary">

      <ion-title style="border: 1px solid #ccc" (click)="scrollToTop()">Pictagram</ion-title>
      </ion-toolbar>
      </ion-header>

      <ion-content cache-view="false">
      <ion-refresher slot="fixed" (ionRefresh)="doRefresh($event)">
      <ion-refresher-content
      pullingIcon="arrow-dropdown"
      pullingText="Pull to refresh"
      refreshingSpinner="circles"
      refreshingText="Refreshing...">
      </ion-refresher-content>
      </ion-refresher>

      <hr no-margin no-padding>
      <div (swipe)="swipePage($event)">

      <!-- Cards -->
      <ion-card no-padding padding-bottom no-margin class="card" *ngFor="let getImage of getImages3">

      <ion-row>
      <ion-col col-10>
      <ion-item>
      <ion-avatar item-left>
      <img *ngIf="getImage.sex == 'male'" src="http://localhost:8000/files/getImage.image ">
      <img *ngIf="getImage.sex == 'female'" src="http://localhost:8000/files/getImage.image ">
      </ion-avatar>

      <b style="width: 222px;display: -webkit-box;padding-left: 11px;">getImage.name</b>

      </ion-item>
      </ion-col>
      <ion-col col-2>

      </ion-col>
      </ion-row>

      <div>
      <img src="http://localhost:8000/files/getImage.image " (click)="tapPhotoLike(getImage.id)">
      </div>


      <p no-margin no-padding>
      <button clear ion-button icon-only class="like-btn">
      <ion-icon no-padding [name]="like_btn.icon_name" color=" like_btn.color " class="icon-space"></ion-icon>
      </button>
      </p>

      <ion-card-content class="padding">
      <p class="like-content">
      <ion-icon class="color" name="heart" ></ion-icon> getcounts likes
      </p>
      <p><b>getImage.title</b>getImage.info</p>

      <ion-note style="font-size: 12px">
      getImage.created_at

      </ion-note>
      </ion-card-content>

      </ion-card>

      </div>
      </ion-content>


      In tab1.page.ts file i am manage the icon please help me how to show icon only for liked post. how to set id please help me...



      tab1.page.ts



      import Component, OnInit from '@angular/core';
      import UserService from '../user.service';
      import User from '../user';
      import first from 'rxjs/operators';
      import Storage from '@ionic/storage';
      import ToastController from '@ionic/angular';
      import LoadingController from '@ionic/angular';
      @Component(
      selector: 'app-tab1',
      templateUrl: 'tab1.page.html',
      styleUrls: ['tab1.page.scss']
      )

      export class Tab1Page implements OnInit

      getImages: User[] = [];
      getImages2: User[] = [];
      getImages3;
      getcounts;
      countLikes
      counts
      unlikes
      public like_btn =
      color: 'danger',
      icon_name: 'heart-empty'
      ;

      public tap: number = 0;

      constructor(private userService: UserService,
      public toastController: ToastController,
      private storage: Storage,
      public loadingController: LoadingController)



      doRefresh(event)
      this.userPost();
      setTimeout(() =>
      event.target.complete();
      , 2000);


      ngOnInit()
      this.userPost();
      this.getCountOfLikes();


      async userPost()
      const loading = await this.loadingController.create(
      message: 'Please wait...',
      spinner: 'crescent',
      duration: 2000
      );
      await loading.present();
      this.userService.getUserPost().pipe(first()).subscribe(getImages =>
      this.getImages3 = getImages;
      //console.log(this.getImages3);
      loading.dismiss();
      );


      likeButton()
      const detail_id = this.userService.getCurrentIdpostId();
      if (this.like_btn.icon_name === 'heart-empty')
      this.like_btn.icon_name = 'heart';
      this.like_btn.color = 'danger';

      this.storage.get('userId').then((val) =>
      if (val)
      this.userService.userPostLikes(val, detail_id).pipe(first()).subscribe(
      async data =>
      //console.log(data);
      if (data['status'] === 'you have already liked this post')
      const toast = await this.toastController.create(
      message: 'you have already liked this post',
      duration: 2000
      );
      toast.present();

      this.getCountOfLikes();


      );

      );


      else
      this.like_btn.icon_name = 'heart-empty';
      this.like_btn.color = 'danger';
      this.unlikePost();
      this.getCountOfLikes();



      tapPhotoLike($detail_id)

      this.userService.setCurrentIdpostId($detail_id);
      this.tap++;
      setTimeout(() =>
      if (this.tap == 1)
      this.tap = 0;
      //alert('Single Tap');
      if (this.tap > 1)
      this.tap = 0;

      this.likeButton();
      //alert('Double Tap');

      , 250);

      ionViewWillEnter()
      this.userPost();
      this.getCountOfLikes();


      getCountOfLikes()

      this.userService.getCountId().pipe(first()).subscribe(likes =>
      this.counts = likes;

      for (var k in this.counts)

      var i = this.counts[k].detail_id;


      this.userService.getUserPostlikes(i).pipe(first()).subscribe(getlikes =>
      this.getcounts = getlikes;
      );
      );


      unlikePost()
      let detail_id = this.userService.getCurrentIdpostId();
      this.storage.get('userId').then((val) =>
      if (val)
      this.userService.unLikes(val, detail_id).subscribe(async dislikes =>
      this.unlikes = dislikes;
      )

      );












      share|improve this question
















      I am making ionic project in my project i want to add double tab likes button .My proble is when tap on image then show likes icon for all post .I want to show only likes post icon .How can resolve this please help me below are my code which is used for likes icon..



      tab1.page.html



       <ion-header>
      <ion-toolbar color="secondary">

      <ion-title style="border: 1px solid #ccc" (click)="scrollToTop()">Pictagram</ion-title>
      </ion-toolbar>
      </ion-header>

      <ion-content cache-view="false">
      <ion-refresher slot="fixed" (ionRefresh)="doRefresh($event)">
      <ion-refresher-content
      pullingIcon="arrow-dropdown"
      pullingText="Pull to refresh"
      refreshingSpinner="circles"
      refreshingText="Refreshing...">
      </ion-refresher-content>
      </ion-refresher>

      <hr no-margin no-padding>
      <div (swipe)="swipePage($event)">

      <!-- Cards -->
      <ion-card no-padding padding-bottom no-margin class="card" *ngFor="let getImage of getImages3">

      <ion-row>
      <ion-col col-10>
      <ion-item>
      <ion-avatar item-left>
      <img *ngIf="getImage.sex == 'male'" src="http://localhost:8000/files/getImage.image ">
      <img *ngIf="getImage.sex == 'female'" src="http://localhost:8000/files/getImage.image ">
      </ion-avatar>

      <b style="width: 222px;display: -webkit-box;padding-left: 11px;">getImage.name</b>

      </ion-item>
      </ion-col>
      <ion-col col-2>

      </ion-col>
      </ion-row>

      <div>
      <img src="http://localhost:8000/files/getImage.image " (click)="tapPhotoLike(getImage.id)">
      </div>


      <p no-margin no-padding>
      <button clear ion-button icon-only class="like-btn">
      <ion-icon no-padding [name]="like_btn.icon_name" color=" like_btn.color " class="icon-space"></ion-icon>
      </button>
      </p>

      <ion-card-content class="padding">
      <p class="like-content">
      <ion-icon class="color" name="heart" ></ion-icon> getcounts likes
      </p>
      <p><b>getImage.title</b>getImage.info</p>

      <ion-note style="font-size: 12px">
      getImage.created_at

      </ion-note>
      </ion-card-content>

      </ion-card>

      </div>
      </ion-content>


      In tab1.page.ts file i am manage the icon please help me how to show icon only for liked post. how to set id please help me...



      tab1.page.ts



      import Component, OnInit from '@angular/core';
      import UserService from '../user.service';
      import User from '../user';
      import first from 'rxjs/operators';
      import Storage from '@ionic/storage';
      import ToastController from '@ionic/angular';
      import LoadingController from '@ionic/angular';
      @Component(
      selector: 'app-tab1',
      templateUrl: 'tab1.page.html',
      styleUrls: ['tab1.page.scss']
      )

      export class Tab1Page implements OnInit

      getImages: User[] = [];
      getImages2: User[] = [];
      getImages3;
      getcounts;
      countLikes
      counts
      unlikes
      public like_btn =
      color: 'danger',
      icon_name: 'heart-empty'
      ;

      public tap: number = 0;

      constructor(private userService: UserService,
      public toastController: ToastController,
      private storage: Storage,
      public loadingController: LoadingController)



      doRefresh(event)
      this.userPost();
      setTimeout(() =>
      event.target.complete();
      , 2000);


      ngOnInit()
      this.userPost();
      this.getCountOfLikes();


      async userPost()
      const loading = await this.loadingController.create(
      message: 'Please wait...',
      spinner: 'crescent',
      duration: 2000
      );
      await loading.present();
      this.userService.getUserPost().pipe(first()).subscribe(getImages =>
      this.getImages3 = getImages;
      //console.log(this.getImages3);
      loading.dismiss();
      );


      likeButton()
      const detail_id = this.userService.getCurrentIdpostId();
      if (this.like_btn.icon_name === 'heart-empty')
      this.like_btn.icon_name = 'heart';
      this.like_btn.color = 'danger';

      this.storage.get('userId').then((val) =>
      if (val)
      this.userService.userPostLikes(val, detail_id).pipe(first()).subscribe(
      async data =>
      //console.log(data);
      if (data['status'] === 'you have already liked this post')
      const toast = await this.toastController.create(
      message: 'you have already liked this post',
      duration: 2000
      );
      toast.present();

      this.getCountOfLikes();


      );

      );


      else
      this.like_btn.icon_name = 'heart-empty';
      this.like_btn.color = 'danger';
      this.unlikePost();
      this.getCountOfLikes();



      tapPhotoLike($detail_id)

      this.userService.setCurrentIdpostId($detail_id);
      this.tap++;
      setTimeout(() =>
      if (this.tap == 1)
      this.tap = 0;
      //alert('Single Tap');
      if (this.tap > 1)
      this.tap = 0;

      this.likeButton();
      //alert('Double Tap');

      , 250);

      ionViewWillEnter()
      this.userPost();
      this.getCountOfLikes();


      getCountOfLikes()

      this.userService.getCountId().pipe(first()).subscribe(likes =>
      this.counts = likes;

      for (var k in this.counts)

      var i = this.counts[k].detail_id;


      this.userService.getUserPostlikes(i).pipe(first()).subscribe(getlikes =>
      this.getcounts = getlikes;
      );
      );


      unlikePost()
      let detail_id = this.userService.getCurrentIdpostId();
      this.storage.get('userId').then((val) =>
      if (val)
      this.userService.unLikes(val, detail_id).subscribe(async dislikes =>
      this.unlikes = dislikes;
      )

      );









      ionic-framework ionic4






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 22 at 10:11







      Er. Dinesh

















      asked Mar 22 at 4:42









      Er. DineshEr. Dinesh

      186114




      186114






















          1 Answer
          1






          active

          oldest

          votes


















          0














          This is an general example of how you can fix your shared button problem.



          1. We are going to make an array which will toggle values. The array will be the size of the data array. Inside we will place all values to false.

          2. If a button is clicked, the index of the data array will be passed and this will change the value of the toggle array to true.


          HTML



          Looping over the data array with index i



          <ion-item *ngFor="let image of images; index as i">
          <ion-button (click)="toggleIcon(i)">
          <ion-icon name="heart-empty" *ngIf="!iconToggle[i]"></ion-icon>
          <ion-icon name="heart" *ngIf="iconToggle[i]"></ion-icon>
          </ion-button>
          </ion-item>


          TS



          If we get the data from the subscribe, we set the toggle array to all false values.
          If the button is clicked, the value of the same index as the data array changes to true and the other icon can be showed in html.



          images = []
          iconToggle = [];

          this.userService
          .getUserPost()
          .subscribe(res =>
          this.images = res;
          this.setIconToggles();
          );

          setIconToggles()
          let x = 0;
          this.images.forEach(() =>
          this.iconToggle[x] = false;
          x++;
          );


          toggleIcon(num: number)
          if (this.orderToggle[num])
          this.orderToggle[num] = false;
          else
          this.orderToggle[num] = true;







          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55293037%2fswitching-one-icon-button-switches-all-icon-buttons-in-my-share-post%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            This is an general example of how you can fix your shared button problem.



            1. We are going to make an array which will toggle values. The array will be the size of the data array. Inside we will place all values to false.

            2. If a button is clicked, the index of the data array will be passed and this will change the value of the toggle array to true.


            HTML



            Looping over the data array with index i



            <ion-item *ngFor="let image of images; index as i">
            <ion-button (click)="toggleIcon(i)">
            <ion-icon name="heart-empty" *ngIf="!iconToggle[i]"></ion-icon>
            <ion-icon name="heart" *ngIf="iconToggle[i]"></ion-icon>
            </ion-button>
            </ion-item>


            TS



            If we get the data from the subscribe, we set the toggle array to all false values.
            If the button is clicked, the value of the same index as the data array changes to true and the other icon can be showed in html.



            images = []
            iconToggle = [];

            this.userService
            .getUserPost()
            .subscribe(res =>
            this.images = res;
            this.setIconToggles();
            );

            setIconToggles()
            let x = 0;
            this.images.forEach(() =>
            this.iconToggle[x] = false;
            x++;
            );


            toggleIcon(num: number)
            if (this.orderToggle[num])
            this.orderToggle[num] = false;
            else
            this.orderToggle[num] = true;







            share|improve this answer



























              0














              This is an general example of how you can fix your shared button problem.



              1. We are going to make an array which will toggle values. The array will be the size of the data array. Inside we will place all values to false.

              2. If a button is clicked, the index of the data array will be passed and this will change the value of the toggle array to true.


              HTML



              Looping over the data array with index i



              <ion-item *ngFor="let image of images; index as i">
              <ion-button (click)="toggleIcon(i)">
              <ion-icon name="heart-empty" *ngIf="!iconToggle[i]"></ion-icon>
              <ion-icon name="heart" *ngIf="iconToggle[i]"></ion-icon>
              </ion-button>
              </ion-item>


              TS



              If we get the data from the subscribe, we set the toggle array to all false values.
              If the button is clicked, the value of the same index as the data array changes to true and the other icon can be showed in html.



              images = []
              iconToggle = [];

              this.userService
              .getUserPost()
              .subscribe(res =>
              this.images = res;
              this.setIconToggles();
              );

              setIconToggles()
              let x = 0;
              this.images.forEach(() =>
              this.iconToggle[x] = false;
              x++;
              );


              toggleIcon(num: number)
              if (this.orderToggle[num])
              this.orderToggle[num] = false;
              else
              this.orderToggle[num] = true;







              share|improve this answer

























                0












                0








                0







                This is an general example of how you can fix your shared button problem.



                1. We are going to make an array which will toggle values. The array will be the size of the data array. Inside we will place all values to false.

                2. If a button is clicked, the index of the data array will be passed and this will change the value of the toggle array to true.


                HTML



                Looping over the data array with index i



                <ion-item *ngFor="let image of images; index as i">
                <ion-button (click)="toggleIcon(i)">
                <ion-icon name="heart-empty" *ngIf="!iconToggle[i]"></ion-icon>
                <ion-icon name="heart" *ngIf="iconToggle[i]"></ion-icon>
                </ion-button>
                </ion-item>


                TS



                If we get the data from the subscribe, we set the toggle array to all false values.
                If the button is clicked, the value of the same index as the data array changes to true and the other icon can be showed in html.



                images = []
                iconToggle = [];

                this.userService
                .getUserPost()
                .subscribe(res =>
                this.images = res;
                this.setIconToggles();
                );

                setIconToggles()
                let x = 0;
                this.images.forEach(() =>
                this.iconToggle[x] = false;
                x++;
                );


                toggleIcon(num: number)
                if (this.orderToggle[num])
                this.orderToggle[num] = false;
                else
                this.orderToggle[num] = true;







                share|improve this answer













                This is an general example of how you can fix your shared button problem.



                1. We are going to make an array which will toggle values. The array will be the size of the data array. Inside we will place all values to false.

                2. If a button is clicked, the index of the data array will be passed and this will change the value of the toggle array to true.


                HTML



                Looping over the data array with index i



                <ion-item *ngFor="let image of images; index as i">
                <ion-button (click)="toggleIcon(i)">
                <ion-icon name="heart-empty" *ngIf="!iconToggle[i]"></ion-icon>
                <ion-icon name="heart" *ngIf="iconToggle[i]"></ion-icon>
                </ion-button>
                </ion-item>


                TS



                If we get the data from the subscribe, we set the toggle array to all false values.
                If the button is clicked, the value of the same index as the data array changes to true and the other icon can be showed in html.



                images = []
                iconToggle = [];

                this.userService
                .getUserPost()
                .subscribe(res =>
                this.images = res;
                this.setIconToggles();
                );

                setIconToggles()
                let x = 0;
                this.images.forEach(() =>
                this.iconToggle[x] = false;
                x++;
                );


                toggleIcon(num: number)
                if (this.orderToggle[num])
                this.orderToggle[num] = false;
                else
                this.orderToggle[num] = true;








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 22 at 10:38









                Tomas VancoillieTomas Vancoillie

                604618




                604618





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55293037%2fswitching-one-icon-button-switches-all-icon-buttons-in-my-share-post%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현