Currently, I am facing a challenge in Angular 2 where I have an array of objects that I need to iterate over. However, I also need to limit the display length of a specific key's string value within each object.
this.productService.loadAllProducts(product).subscribe(data => {
if (this.authService.checkActiveSession(data)) {
if (data.success) {
//console.log(this.product_desc.substring(0,2))
for(let i=0;i<data.products.length ;i++){ //I'm struggling with iterating properly here!!
console.log(data.products[0].product_desc)
}
this.source.load(data.products);
} else {
console.log('Not binded');
}
}
});
}
To achieve this, I've attempted to limit the length of the product description to 10 characters by using:
For example:
this.product_desc.substring(0,10)