Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

this.nav.to is undefined

Hello all,

            I have created two views and now i want to navigate from first view to second view.I have return the code for it but its showing an error

  i.e.TypeError: this.nav is undefined

can any1 please help me my code is written below

-------------

sap.ui.controller("toggle.toggle", {

    OnPress : function (evt) {

        var context = evt.getSource().getBindingContext();

        this.nav.to("toggle1", context);

        }

-----------------------------------------------------

               first view

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"

        controllerName="toggle.toggle" xmlns:html="http://www.w3.org/1999/xhtml">

    <Page title="Title1">

<!--         <content> -->

    <Button

                    text=" Button"

                    press="OnPress"/>

<!--         </content> -->

    </Page>

</core:View>

-------------------------------------------------------------------

     2nd view

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"

        controllerName="toggle.toggle1" xmlns:html="http://www.w3.org/1999/xhtml">

    <Page

  title="View2"

  showNavButton="true"

  navButtonPress="handleNavBack" >

        <content>

                   

        </content>

    </Page>

</core:View>

-----------------------------------------------------------------------

         2nd controller

ap.ui.controller("toggle.toggle1", {

    

    handleNavBack : function (evt) {

      this.nav.back("toggle1");

      }

});

Former Member
Not what you were looking for? View more on this topic or Ask a question