How to fix this.router is not a function error. The current application in development performs navigation from view 1 to view 2. and comes back to view 1 from view 2 . Every thing works fine unless i reload the application in view 2 and performs a nav back function to come back to view 1.
View2 :
onInit function () { var oRouter = sap.ui.core.UIComponent.getRouterFor(this); oRouter.getRoute("view2routername").attachPatternMatched(this._onObjectMatched1, this); } this.getOwnerComponent().getModel().metadataLoaded().then(function() { // Restore original busy indicator delay for the object view oViewModel.setProperty("/delay", iOriginalBusyDelay); });
View 2
onNavBack: function () { var oHistory = History.getInstance(); var sPreviousHash = oHistory.getPreviousHash(); if (sPreviousHash !== undefined) { window.history.go(-1); } else { var bReplace = true; this.getRouter().navTo("myview1routername", {}, bReplace); } }
If the app is refreshed / loaded at view 2 throwing this.router is not a function error. pointing to line 9. Otherwise it works perfectly fine.
Any suggestions