我的错误仅在Dim tables = SplitTable(dt, 8)
之后抛出,但在ng serve --prod
之后一切正常。
ng serve
ERROR in component.html(5,24): : Property 'id' does not exist on type 'ProductModel'.
<div *ngIf="product?.id">{{product.id}}</div>
product: ProductModel;
constructor( public bcProductService: BcProductService) {
this.bcProductService.getProductById(id).subscribe(single => {
return this.product = single.data;
});
}
错了吗?为什么它适用于开发而不是this.product
?--prod
似乎有一层额外的错误
如何确保在开发模式下看到所有错误?它是否像在ng build --prod
中构建一样简单?但是对于environment.ts vars呢?答案 0 :(得分:2)
请勿使用product?.id
而是使用product && product.id ? true : false
或创建方法productExists()
,它会为if
返回true / false。 - 这可能与AoT有关(提前 - 可能在生产编译中使用) - 我在this angular-framework中找到了这些信息。