我有一个类似
的组件import { Component } from '@angular/core';
interface ItemBaseType {
foo: boolean;
}
interface ItemType extends ItemBaseType {
bar: boolean;
}
@Component({
selector: 'ac-foo',
template: `<div *ngIf="item.bar">Hello</div>`,
})
export class FooComponent {
public item: ItemType;
}
我已在Angular 9应用上启用fullTemplateTypeCheck and strictTemplates ,并且在运行ng serve
时引发异常:
类型“ ItemBaseType”上不存在属性“栏”。
但是bar
存在于ItemType
上。
出了什么问题?
答案 0 :(得分:1)
在这种情况下,您可以使用item..bar。希望对您有所帮助。