Reputation: 1730
There is an array:
var stringArray = new Array();
stringArray[1] = 'one';
And ngFor renders nothing in angular when stringArray[0] = undefined.
How do I solve it?
Upvotes: 0
Views: 517
Reputation: 14750
If you want to exclude undefined
, null
and empty
values from your template, you could simply filter your data source:
private source = [
undefined,
null,
"",
"Hello World"
];
public stringArray = source.filter(i => i);
Upvotes: 1
Reputation: 5267
That should work fine. I used ng-container
for loop with ngFor
and ngIf
in a < li >
I was able to replicate that in stackblitz here is the link:
https://stackblitz.com/edit/angular-a2xph9?file=src%2Fapp%2Fapp.component.html
Upvotes: 1