ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 275.4k

How to remove item if exist before and add current as new ?

May 17 2020 6:15 AM

problem
How to remove item if exist before and add current as new ?
I need when add statusdate exist before on collectfulldata then remove exist and and add new one
and if not exist add it .
meaning i dont need two statusdata with same name exist two time .
and if statusdata not exist add it .
  1. initcollectdropdowslist=[];  
  2. collectfulldata:string;  
  3. let textdata=$event.target.options[$event.target.options.selectedIndex].text;  
  4. let statusdata:any = this.FilterBinddata.filter(s=>s.reportSource==textdata)[0].reportSource2;  
  5. this.collectfulldata= statusdata + "=" + "'" + textdata + "'";  
  6. this.initcollectdropdowslist.push(this.collectfulldata);  
  7. console.log("full data is " + this.initcollectdropdowslist)  
current result
  1. full data is Text5='Lifecycle',Text6='Package',Text7='Parametric'  
Expected result
if add Text8='car' to collectfulldata add it because not exist
if add Text6='OBS' add it but remove exist as Text6='Package'


Answers (4)