sap.ui.define(["mvcapp00124/controller/BaseController"], function (Controller) { "use strict"; /** * @param {typeof sap.ui.core.mvc.Controller} Controller */ return Controller.extend("mvcapp00124.controller.Details", { onInit: function () { // bind the function _onRouteMatched to the event of navigating to the pattern "flights" this.getOwnerComponent() .getRouter() .getRoute("flights") .attachPatternMatched(this._onRouteMatched, this); }, _onRouteMatched: function (oEvent) { // get the flight id which was navigated to let sFlightId = oEvent.getParameter("arguments").flightId; // get the flight data let oData = this.getOwnerComponent().getModel().getData(); // search for the flightId in the flight data let iIndex = oData.Flight.findIndex((oFlight) => oFlight.flightId === sFlightId); // bind the view to the selected flight this.getView().bindElement("/Flight/" + iIndex); }, }); });