I am trying to iterate over the properties of an object with *ngFor, but using in. When i try to do it
@Controller({
selector: 'sample-controller',
template: `
<ul>
<li *ngFor="let i in obj">
<b>{{i}}</b>: {{obj[i]}}
</li>
</ul>`
})
class SampleController {
obj = {a: 1, b: 2}
}
I get an error message:
You cannot bind to 'ngForIn', since this is not a known property of 'li'.
I turned on FormsModuleand BrowserModulein the section imports @NgModulefor this component.
Is it possible to use ngForInon li, and if not, is there an idiomatic alternative?
source
share