Skip to content
Advertisement

Iterate over array of objects in Typescript

I need to iterate over the array of objects in angular 2 and limit the string length display for a particular key in the object.

JavaScript

I need to limit the prod_desc length to (say) 10 characters while displaying for which I have used:

Eg:

JavaScript

Advertisement

Answer

You can use the built-in forEach function for arrays.

Like this:

JavaScript

Your version wasn’t wrong though. It should look more like this:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement