SAPui5路由传递参数

时间:2016-07-05 12:17:28

标签: routing sapui5

我试图通过路由传递参数作为此链接中的第32步(https://sapui5.netweaver.ondemand.com/docs/guide/2366345a94f64ec1a80f9d9ce50a59ef.html),但它不起作用,我不知道我在做什么做错了:

ListController

        onPressItemDetail: function(evt) {

        var oSource = evt.getSource();
        var oBind = oSource.getBindingContext();
        var sPath = oBind.getPath();

        var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
        oRouter.navTo("changeitem", { path : sPath});

    },

的manifest.json

        "routes": [{
            "pattern": "",
            "name": "first",
            "target": "first"
        }, {
            "pattern": "secondview",
            "name": "second",
            "target": "second"
        }, {
            "pattern": "checkout",
            "name": "checkout",
            "target": "checkout"
        }, {
            "name": "changeitem/{path}",
            "pattern": "changeitem",
            "target": "changeitem"
        }],

changeitemcontroller

    onInit: function() {
        var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
        var rChangeItem = oRouter.getRoute("changeitem");
        rChangeItem.attachPatternMatched(this._onObjectMatched, this);
    },

    _onObjectMatched: function (evt) {

        this.getView().bindElement({
            path: "/" + evt.getParameter("arguments").path,
            model: "item"
        });

    },

显示的错误是:无法导航到名称为changeitem的路由,因为该路由不存在..

1 个答案:

答案 0 :(得分:1)

您已将pattern分配给路线的name属性。

应该是:

{
    "name": "changeitem",
    "pattern": "changeitem/{path}",
    "target": "changeitem"
}