遍历 angular 9 中未排序的对象

Iterating through unsequenced object in angular 9

Object structure 我想遍历一个复杂对象,我想要 ngbtypeahead 中的所有值,在此之前我无法从这个复杂对象中获取这些值,因为键不同。

***> Special Tests: {
                       244: "Immunohistochemistry (IHC)", 
                       245: "Flowcytometry", 
                       246: "PET scan"
                     }
     TUMOUR MARKERS: {
                       24: "CEA",  
                       25: "PSA", 
                       26: "AFP",  
                       27: "CA 125"
                     } ***

我猜你的选项应该是 "Immunohistochemistry (IHC)", "Flowcytometry", "PET scan", "CEA", "PSA", "AFP", "CA 125" ...。 所以你需要复杂对象的值:

const options = Object.values(yourComplexObject)
  .reduce((options, subObject) => [...options, ...Object.values(subObject)], [])