“收藏夹”按钮呈角度显示,注销和登录后收藏的产品颜色消失

时间:2019-09-04 17:28:25

标签: angular favicon favorites

当单击“收藏夹”按钮时,它将获得收藏夹,而当我取消收藏夹时,它将变得收藏夹。但是问题是,如果该产品是我的最爱,然后注销并登录。然后它不会显示为喜欢的颜色,但功能正常。只有颜色不能正常工作。对于每个人都在说,isFavorite的值不会在应用程序的整个生命周期中持续存在。一旦销毁了此组件,isFavorite也将销毁。请就这些帮助我

`Favorite.component.html`

`<button class="favouri" (click)="isFavoritee(x.ad_Id)"><i class="fa"
[ngClass]="{'fa-heart' : isFavorite[x.ad_Id], 'fa-heart-o': !isFavorite[x.ad_Id] }"></i></button>`

`Favorite.component.ts`

`isFavorite: boolean[]  = [];`

`isFavoritee(elem: any) {
    // this.toggle = !this.toggle;
    this.isFavorite[elem] = !this.isFavorite[elem];
    this.favouritedata = [];
    const favo = {
      'login_Id': this.localservice.getLoginId() ? this.localservice.getLoginId() : '',
      'ad_id' : elem ? elem : '',
      'category_Id' : 27,
      'mode': 'INSERT'
    };
    this.authservice.post('/api/Favourite/insert', favo).subscribe(data1 => {
      this.favouritedata = data1;
      console.log(this.favouritedata);
    }, error => {
      alert('something went wrong');
    });
  }`

0 个答案:

没有答案