sapui5如何根据后台响应创建控件?

How to create controls based on the backend response in sapui5?

我想根据服务中提供的后端数据生成 UI。

我的服务如下所示:

    {
    "ControlData": {
        "results": [{
            "Label": "Gender?",
            "Type": "COMBOBOX"
        }],
        "ControlValues": {
            "results": [{
                    "Key": "M",
                    "Value": "Male"
                },
                {
                    "Key": "F",
                    "Value": "Female"
                }
            ]
        }
    }
}

这里我想生成一个 ComboBox 控件,其中包含服务中动态提供的标签和值。

请提供任何示例或参考。

你需要使用工厂函数

使用工厂函数

Step 15: Aggregation Binding Using a Factory Function