使用组件方法禁用 Angular 按钮是好还是坏?具体来说,这会是 Angular 中的性能问题吗?看来Angular必须不断计算。
使用静态变量(例如 this.productDisable: boolean)是否更好,让它在特定时间进行计算?
isProductSaveDisabled() {
if (this.productsSelected == null || this.productsSelected ?.length === 0) {
return true;
} else {
return false;
}
}
HTML:
<button mat-raised-button [disabled]="isProductSaveDisabled()" (click)="saveAll()">
Save Product
</button>
使用类方法等好奇地阅读教程和文章的战利品