How to dynamically load an XML fragment in XML view?

前端 未结 2 1927
有刺的猬
有刺的猬 2021-01-05 17:04

Suppose I have the following XML view:


    
        &l         


        
2条回答
  •  渐次进展
    2021-01-05 17:12

    I think the only solution will be initialization of fragment from onInit method of controller:

    sap.ui.controller("my.controller", {
        onInit : function(){
            var oLayout = this.getView().byId('mainLayout'), //don't forget to set id for a VerticalLayout
                oFragment = sap.ui.xmlfragment(this.fragmentName.bind(this));
            oLayout.addContent(oFragment);
        },
    
        fragmentName : function(){
           return "my.fragment";
        }
    });
    

提交回复
热议问题