Type casting within a template in Angular 2

后端 未结 3 1747
春和景丽
春和景丽 2020-12-15 16:43

I\'m working on an Angular project (Angular 4.0.0) and I\'m having trouble binding a property of an abstract class to ngModel because I first need to cast it as the concrete

3条回答
  •  一生所求
    2020-12-15 16:54

    If you don't care about type control.

    In Angular 8 and higher versions

    [(ngModel)]="$any(event).acknowledged"
    

    https://angular.io/guide/template-typecheck#disabling-type-checking-using-any

提交回复
热议问题