How can I initialize an array of custom objects in javascript to prevent the error "Cannot read property 'length' of undefined"?
component
export class MyClass implements OnInit {
myArray: MyObject[];
}
view
<div *ngIf="myArray.length > 1">Size is greater than 1</div>
The code above rightly gives the mentioned error. What is the right way to initialize the array? Thanks.