I want to iterate through an array of objects and acces the property values of that iterated object in typescript.
Doing this in c#, it's just a matter of performing a foreach through the array.
In typescript this seems a bit different. We can do a foreach, but we dont have access to 'complete' object, how to do this?
@Input() gridDefinitions: GridColumnDefinition[]
public test() {
for (var def **in** this.gridDefinitions){
var test = <GridColumnDefinition>this.selectedObject;
let castedtype = <GridColumnDefinition>def; // this gives an error
}
}
UPDATE: I just ran into the solution. Problems lies in how to iterate through the collection. When using of in stead of in we can access the iterated object. See TypeScript for-in statement