我的 json 数据中有很多这样的条目。 “类型”由两个属性组成,即收入和支出。如何使用 JavaScript 打印 type="expense"的“标签”。 下面的 json 数据只是一个示例。 Check the image to get a better idea of json data.
"expenses_veterinary":{
label:"Veterinary, breeding, and medicine"
name:"expenses_veterinary"
total:0
type:"expense"
}
console.log($ctrl.gold_standard_categories); prints all the json data.
我尝试了下面编写的代码,但它不起作用。
if($ctrl.gold_standard_categories.name.type=expense){
console.log($ctrl.gold_standard_categories.label);
}
最佳答案
关于javascript - 如何为json数据添加过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44095162/