作者:手机用户2502852037 | 来源:互联网 | 2022-12-08 13:43
我的问题非常简单,我有一个以下的JSON Typescript对象,我喜欢迭代JSON属性
{"work_type":"Fabricación","work_type_resp":"Mesa","looking_for":"Relación Calidad/Precio","image":"https://s3-sa-east-1.amazonaws.com/online-quotation-images/153366018967.png","width":"22","high":"34","depth":"","modifications":"mod"}
使用的代码是以下角度TypeScript组件:
export class DetailsOnlineQuoteModalComponent implements OnInit {
@Input() title;
@Input() values:string;
properties:JSON;
constructor(public activeModal: NgbActiveModal) { }
ngOnInit() {
this.properties=JSON.parse(this.values);
console.log(this.properties);
}
}
我真正需要的是通过JSON的键值属性并在我的HTML中显示它们.
非常感谢!
1> Chellappan..:
如果您使用角度6.1使用keyvalue管道
{{title.key}}
对于Angular 5
{{key}} ------------- {{data[key]}}
get dataKeys() { return Object.keys(this.data); }
示例:https://stackblitz.com/edit/keyvalue-pipe-qtaqnm