dzenlife
1/28/2020 - 1:48 PM

Angular TypeScript

push, splice

public async addAddress()
{
  this.data.addresses.push({
        from: { 
            title: '',
            radius: 0
        },
        to: { 
            title: '',
            radius: 0
        }
    });
  // Sleep thread for 3 seconds
  await this.delay(500);
    this.refreshFias();
}

public async removeAddress()
{
    this.data.addresses.splice(this.data.addresses.length-1, 1);
  await this.delay(500);
    this.refreshFias();
}

private delay(ms: number)
{
  return new Promise(resolve => setTimeout(resolve, ms));
}