Skip to Content
-1

Cannot read property 'navTo' of undefined

I am trying do a navigation button in my sapui5 aplication deployed on Fiori

_onPageNavButtonPress: function () {
        var oHistory = History.getInstance();
        var sPreviousHash = oHistory.getPreviousHash();

        if (sPreviousHash !== undefined) {
            window.history.go(-1);
        } else {
            var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
            oRouter.navTo("default", true);
        }

    },


But when I click in the nave button in the console show Cannot read property 'navTo' of undefined

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Apr 24, 2017 at 07:13 PM

    I solved it.

    Below is my new code

    onInit: function(){
    			  var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
    			},
    			
    			onBack: function(){
    			var oHistory = sap.ui.core.routing.History.getInstance();
    			var sPreviousHash = oHistory.getPreviousHash();
    			window.history.go(-1);
    			},
    
    Add comment
    10|10000 characters needed characters exceeded

  • Apr 20, 2017 at 07:15 PM

    show me the code where you call _onPageNavButtonPress.

    Add comment
    10|10000 characters needed characters exceeded