Code inside my View is as follows:-
My First View Page:- View1.view.xml
<mvc:View xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="StartApplication.controller.View1">
<Page title="Welcome to First Page" id="idpage1">
<content>
<Button text="Click me!!" press="Click" busy="false" type="Accept"/>
</content>
</Page>
</mvc:View>
Code of my Second View:- Pge2.view.xml
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="StartApplication.controller.Pge2"
xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="Welcome to Page2">
<content>
<Text text=" Navigation successful.."></Text>
</content>
</Page>
</mvc:View>
Code of my Controllers:-
My first controller :- View1.controller.js
sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) {
"use strict";
return Controller.extend("StartApplication.controller.View1", {
/**
*@memberOf QuickStartApplication.controller.View1
*/
Click: function () {
//This code was generated by the layout editor.
//this.navTo("");
this.getRouter().navTo("page2");
}
});
});
Note:- I have added any code inside Pge2.controller.js
Code inside Component.js:-
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/Device",
"StartApplication/model/models"
], function(UIComponent, Device, models) {
"use strict";
return UIComponent.extend("StartApplication.Component", {
metadata: {
manifest: "json"
},
/**
* The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
* @public
* @override
*/
init: function() {
// call the base component's init function
UIComponent.prototype.init.apply(this, arguments);
this.getRouter().initialize();
// set the device model
this.setModel(models.createDeviceModel(), "device");
}
});
});