I think your disable directive is not able to calculate option.value.dynamicAttributeList
. Looking at the way you have used your ngfor below:
<mat-option *ngFor="let attributeDetail of option.value.dynamicAttributeList"
[value]="attributeDetail.optionValue"
[disabled]="attributeDetail.disabled === true"
[ngStyle]="{'background-color': attributeDetail.optionValue}">
{{attributeDetail.optionValue}}
</mat-option>
and considering that option.value.dynamicAttributeList
already works and correctly fetches data from your object using ngfor, I would suggest that instead of using disabled like this:
[disabled]="option.value.dynamicAttributeList.length === countForSize || option.value.dynamicAttributeList.length === countForColor"
use this and that should make it work:
[disabled]="option.value.dynamicAttributeList?.length === countForSize || option.value.dynamicAttributeList?.length === countForColor"
Reason: (?) here is known as 'safe navigation operator', it avoids throwing undefined or null exception when faced with any null values while accessing object properties.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…