Some checks failed
gitea/abap_tutorial_11/pipeline/head There was a failure building this commit
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
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);
|
|
},
|
|
});
|
|
}); |