Showing posts with label Angular. Show all posts
Showing posts with label Angular. Show all posts

Lambda in Angular (typescript)

Posted on by Kim

return books.bar.filter(function (x) {
  return x.id === null;
}).length;

change to

return books.bar.filters(b => b.id === null).length;

timeout

Posted on by Kim

setTimeout(() = > {
  this.valueField.nativeElement.focus();
}, 1);

Stop many call to backend

Posted on by Kim

private saveTimer;

saveSettings() {
  if(this.saveTimer) {
    clearTimeout(this.saveTimer);
  }
  this.saveTimer = setTimeout(() => {
    // Call service...   
    .....
  }, 500);
}