Json 如何使用sap ui5在popover中添加项目列表?

Json 如何使用sap ui5在popover中添加项目列表?,json,list,popover,sapui5,Json,List,Popover,Sapui5,我正在尝试在popover中添加项目列表,但不知何故无法正常工作:/ 我用JSON文件中的数据填充列表。请在下面找到我的代码: var popoverButton = new sap.ui.unified.ShellHeadItem("popoverButton",{ tooltip: "Configuration", icon: "sap-icon://generate-shortcut", showSeparator:false,

我正在尝试在popover中添加项目列表,但不知何故无法正常工作:/ 我用JSON文件中的数据填充列表。请在下面找到我的代码:

var popoverButton = new sap.ui.unified.ShellHeadItem("popoverButton",{
         tooltip: "Configuration",
         icon: "sap-icon://generate-shortcut",
         showSeparator:false,
         press:function(oEvent){

                   var oButton = oEvent.getSource();

                    if (!this._oPopover){
                        this._oPopover = new sap.m.Popover("popover",{
                            id:"pop",
                            placement:sap.m.PlacementType.Bottom,
                            showHeader:false,
                            contentWidth:"320px",
                            contentHight:"500px"

                            });

                 }

                    this._oPopover.openBy(oButton);


            this._oPopover.addContent(oList);
                    return ("pop");    
                }

        }); 


    var oTemplate = new sap.m.StandardListItem({
        title : "{title}",  
        icon:"{icon}",
        description: "{description}",
        type : sap.m.ListType.Active});

    var oList = new sap.m.List({ 
        items : {path:"/Menu", template:oTemplate}


            });
这就是我在控制器中加载JSON文件的方式:

var oModel = new sap.ui.model.json.JSONModel("model/menu.json");
this.getView().setModel(oModel);

不幸的是,popover仍然是空的:/

我认为您需要在popover上设置您的模型,而您目前没有这样做:

this._oPopover.setModel(oModel); //note you must do this after the model is accessible
或者,在我看来,一个更好的方法是添加popover作为依赖于视图的,如下所示:

...

if (!this._oPopover){
  this._oPopover = new sap.m.Popover("popover",{
    id:"pop",
    placement:sap.m.PlacementType.Bottom,
    showHeader:false,
    contentWidth:"320px",
    contentHight:"500px"
  });
}

//Add the popover as a view dependent, giving it access to the view model
this.getView().addDependent(this._oPopover);

...
让我知道你进展如何