Iterate over object in Angular

前端 未结 17 1557
攒了一身酷
攒了一身酷 2020-11-22 12:19

I am trying to do some things in Angular 2 Alpha 28, and am having an issue with dictionaries and NgFor.

I have an interface in TypeScript looking like this:

17条回答
  •  萌比男神i
    2020-11-22 12:55

    The dictionary is an object, not an array. I believe ng-repeat requires an array in Angular 2.

    The simplest solution would be to create a pipe/filter that converts the object to an array on the fly. That said, you probably want to use an array as @basarat says.

提交回复
热议问题