Fiori2.0-How to pass the Parameterin in the different views?

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_41012753/article/details/79091989

In manifest.json of routers we add parameter’s Path.

这里写图片描述

Overview.view.xml

这里写图片描述
Detail.view.xml

这里写图片描述
Overview.controller.js
We need o get the click path

onPress: function(oEvent) {
    var oItem = oEvent.getSource();

    var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
    oRouter.navTo("detail", {
                invoicePath: oItem.getBindingContext("invoice").getPath().substr(1)
//substr meaning that getPath’s first node
            });
        }

Detail.controller.js

onInit: function () {
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
//I think this step could to get the parameter’s Path   
oRouter.getRoute("detail").attachPatternMatched(this._onObjectMatched, this);
//according for onObjectMatched to binding model
        },
_onObjectMatched: function (oEvent) {
    this.getView().bindElement({
        path: "/" + oEvent.getParameter("arguments").invoicePath,
        model: "invoice"
            });
        }

猜你喜欢

转载自blog.csdn.net/weixin_41012753/article/details/79091989