IGDB API,离子,角度

时间:2018-02-10 14:45:01

标签: angularjs ionic-framework

有任何想法,我如何在Typescript或JS中分割这些:

{“AED”:“阿拉伯联合酋长国迪拉姆”,“AFN”:“阿富汗阿富汗人”,“所有人”:“阿尔巴尼亚人列克”}

我只想要这样的名字:

AED AFN ALL

2 个答案:

答案 0 :(得分:0)

你做错了,首先修改你的objectarray of objects,如下所示

let currencies = [
  {
    code: "AED",
    fullName: "United Arab Emirates Dirham"

  },
  {
    code: "AFN",
    fullName: "Afghan Afghani"

  },
  {
    code: "ALL",
    fullName: "Albanian Lek"

  }
];

现在你可以像

那样遍历它
currencies.forEach(val => {
  //use val.code to get desired currencies codes
})

答案 1 :(得分:0)

您可以使用Object.keyslink)从某个对象中提取所有键。

var countries = { "AED": "United Arab Emirates Dirham", "AFN": "Afghan Afghani", "ALL": "Albanian Lek" }
var codes = Object.keys( countries );
console.log( codes ); // [ "AED", "AFN", "ALL" ]