How to check type of variable in ngIf in Angular2

后端 未结 5 2036
鱼传尺愫
鱼传尺愫 2020-12-14 05:23

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 positio

5条回答
  •  有刺的猬
    2020-12-14 06:02

    Alternatively, you can compare the constructor name.

    {{ foo.constructor.name === 'FooClass' }}
    

    Detailed info about this here.

提交回复
热议问题