Skip to content
Advertisement

Why mat-option text is not rendering in view sometimes?

I have a form where there is a mat-select field. The mat-select field will show value even if the option doesn’t match the list of options. Please take a reference of this stackblitz example.

In this example, on button click, I am adding a value in a form that doesn’t match with theJSON values. The same thing I have implemented is working only on the initial page load but not on another button click. The get function is though returning true but in view, I cannot see the text in option.

component.ts

JavaScript

component.html

JavaScript

Please help me out.

Advertisement

Answer

Please add this code in your component.ts in action function

JavaScript

Then it will add the ‘z’ value in your dropdown option.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement