简体   繁体   English

选择和取消选择在角度7中不起作用?

[英]select and unselect is not working in angular 7?

Hi am making a filter by selecting a icon it highlighted the section and after unselect it doesn't highlighted it but when i select it it works fine but on unselect its icon is disappeared and also it is still selected when i refresh the page, please check this images for reference when selected and when i unselect it and when i refresh the page it show like this 嗨,我正在通过选择一个图标突出显示该部分来制作过滤器,而取消选择后它并未突出显示它,但是当我选择它时,它可以正常工作,但是在取消选择时,它的图标消失了,并且当我刷新页面时它仍然处于选中状态,请检查此图像以供选择时取消选择时以及刷新页面时显示以供参考

here is my working code 这是我的工作代码

HTML Code - HTML代码 -

<div class="flexcell">
 <a *ngIf="data.showcase==1||helper.checkArticleArray(showcasearticle,data.articleid)"
             href="javascript:void(0);"
            (click)="setShowcase(data.articleid,$event)"><svg
             xmlns="http://www.w3.org/2000/svg" width="18" height="18"
             viewBox="0 0 18 18">
           <g id="Group_35" data-name="Group 35"
           transform="translate(-556 -363)">
           <rectid="Rectangle_37" data-name="Rectangle 37"
           width="18" height="18" rx="2"
           transform="translate(556 363)" fill="#2262a0" />
          <path id="star" />
     </g>
     </svg></a> 

Here is my Node code 这是我的节点代码

showcase(articleid,articlepara){

return this.http.post<any>(this.SERVERURL + this.AppSettings.showcase, {articleid: articleid, articlepara : articlepara});

} }

and Here is my .ts file 这是我的.ts文件

   `setShowcase(articleid, event) {
    event.currentTarget.style.display = "none";

    this.article.showcase(articleid, this.articlepara)
      .subscribe(
        res => {
          //console.log(res);
          this.showcasearticle.push(res.articleid);
          console.log(this.showcasearticle);

        },
        err => {
          console.log(err);
        }
      )
  } 

` `

You are setting event.currentTarget.style.display = "none"; 您正在设置event.currentTarget.style.display =“ none”; which is causing it to disappear. 这导致它消失。 What you need is to replace the fill color. 您需要替换填充颜色。 You can refer to this to know more about svg manipulation in angular Angular: transclusion, set color of SVG element 您可以参考此内容,以了解有关角度Angular中的 svg操作的更多信息:包含,设置SVG元素的颜色

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM