【发布时间】:2018-02-23 03:15:52
【问题描述】:
我需要遍历 angular 2 中的对象数组,并限制对象中特定键的字符串长度显示。
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++){ //How to properly iterate here!!
console.log(data.products[0].product_desc)
}
this.source.load(data.products);
} else {
console.log('Not binded');
}
}
}); }
我需要将 prod_desc 长度限制为(比如说)10 个字符,同时显示我使用过的字符:
例如:
this.product_desc.substring(0,10)
【问题讨论】:
标签: javascript angular typescript