简体   繁体   English

如何在angular4中的click事件上传递带有标签的值

[英]how to pass values with their labels on click event in angular4

I want to hide the li when clicking the plus button. 我想在单击加号按钮时隐藏li。 here my data are passing but li is not clearing .(my output is like when clicking the plus button the datas are move but still the li is there.i want to remove the li instance) 这里我的数据正在传递但li没有清除。(我的输出就像单击加号按钮时数据正在移动,但li仍然存在。我想删除li实例) 在此处输入图片说明 my html code is 我的html代码是

 <div class="searchResult-Container">
     <ul>
    <li *ngFor="let stocks of products"
     [class.selected]="stocks === selectedStock"
     (click)="onSelected(stocks)">
      <div class="row searchItem" style="margin:0px;">
       <!--search item starts-->
     <div class="col-md-10 col-sm-10 col-xs-12">
      <div class="row">
         <div class="col-md-6 col-sm-6 col-xs-12 hidden">
   <label>Item</label>
     <span>{{stocks.ItemID}} </span>
       </div>

and my TS code is 我的TS代码是

    onSelected(IComboDetails: IComboDetails): void {
    this.selectedStock = IComboDetails;

}

Looks like you want to remove all items you click plus 您似乎要删除所有单击的项目,再加上

   onSelected(comboDetails: IComboDetails): void {
      const index = this.products.indexOf(comboDetails);
      if (index !== -1) {
        this.products.splice(index, 1);
      }  
   }

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

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