I have been utilizing the code snippet below to populate values in an input field. Setting values of input fields with Angular 6
<input matInput placeholder = "ProductName" [(ngModel)]="orderLine.productname">
However, there are instances where the value could be null. While attempting to handle this by using the question mark ?, I encountered an error. Is it feasible to insert a possible blank or null value into an input field, or is it not achievable?
<input matInput placeholder = "ProductName" [(ngModel)]="orderLine?.productname">
The syntax error occurred when trying to use the '?.' operator for assignment: [[orderLine?.productname=$event]