0
votes

I'm trying to passing parameter through routing as step 32 in this link,(https://sapui5.netweaver.ondemand.com/docs/guide/2366345a94f64ec1a80f9d9ce50a59ef.html) but it's not working, I don't know what I'm doing wrong:

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"
        });

    },

The error showed is : Can not navigate to route with name changeitem because the route does not exist..

1

1 Answers

1
votes

You have assigned pattern to name property of route.

It should be:

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