I'm try to access the router inside a function that is called by another function, and the error message is:
Uncaught TypeError: Cannot read property 'navTo' of undefined
sap.ui.controller.loginSuccess
request.onreadystatechange
I created a JSON model to connect in my server to authenticate the user, when I have a successful authentication, I call the loginSuccess from my controller.
Inside the controller I try to get the router to navigate in my pages.
login:function(){
var login = new Login();
login.loginAuth(
this.byId("user").getValue(),
this.byId("passwd").getValue(),
this.loginSuccess, this.loginError );
this.clear();
},
loginSuccess: function(type){
var router = sap.ui.core.UIComponent.getRouterFor(this);
if(type == "TIPO 1")
router.navTo("MainPage", false);
if(type == "TIPO 2")
router.navTo("SupportMainPage", false);
if(type == "TIPO 3")
router.navTo("ManagerMainPage", false);
},
Why can't I access the methods of my controller inside this function? I tried to access the this.getView() and doesn't work too.
How can I solve this?
Thanks