'Angular: router.navigate does not resolve

Basic html:

<i *ngIf="beforeEnabled" (click)="onBeforeItem(data.currentItem)" class="spicon spicon-down item-before"
                      matTooltip="{{ 'order.home.items.tooltip.before-item'| translate:locale.language }}"
                      [matTooltipPosition]="tooltip.position" [matTooltipShowDelay]="tooltip.showDelay"></i>

Basic typescript:

onBeforeItem(item: OrderItem): void {
    const itemBeforeIndex = item.indexnumber--;
    this.router.navigate(['/order-management/orders/' + this.orderId + '/item/' + itemBeforeIndex]).then(wasOk=> console.log(wasOk)).catch(e => console.error(e));
  }

Click #1 does not work and prints null to the console. Click #2 right after works, navigates correctly and prints true;

No error in the console at all.

Why does click #1 not do anything?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source