Array in the Angular template

0

I have the following code in ts, where it shows a code, which is that, every time I click on a button; I will decrease an array and when there is only one array, do not erase it; but to show it for more than click on the button.

removeCostCenter() { 
    if (this.costCenter[+1]) {
      let pos = this.costCenter.indexOf(name);
      this.costCenter.splice(pos, 1);
    } 
    else {
      this.costCenter.splice(1);
    }
  }

The code works; but he is doing an unnecessary search; I need to know the way that search does not make me; but save me the search; to achieve this, it is done from the template.

Please; Could you tell me how I could do it from the template?

    
asked by Jhonatan Cardona Valencia 30.04.2018 в 21:19
source

0 answers