I'm learning Angular2. I have a component with a variable which is an object.
I'm iterating over the fields of the object, and acording to the type of data of that position, I need to render a different compoenent.
In this case, I want tu render that label
if the typeof
that position is a number
how ever this is not working
<div>
<div *ngIf='obj'>
<label *ngFor="let key of keys; let i = index">
<label class='key'>{{key}}:</label>
<label class='number' *ngIf='typeof obj[key] === "number"'>
<!-- label class='number' *ngIf='obj[key] | typeof === "number"' -->
{{ obj[key] }}
</label>
</label>
</div>
</div>
Any ideas?
I have also created a pipe to get the typeof
which work when I print the value, but not inside the *ngIf
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…