Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Function of one (first) SAPUI5 view controller can be called from another (second) SAPUI5 view controller -


if this function is subscribed to some event of EventBus in the first controller:



onInit: function() {
    sap.ui.getCore().getEventBus().subscribe(
        "SomeChannel",
        "SomeEvent",
        this.someFunctionOfTheFirstController,
        this
    );
},
someFunctionOfTheFirstController: function (sChannelId, sEventId, sData) {
    console.log(
        "Function of the first controller " + sData
    );
}


and the same event of EventBus is published in the second controller:



functionOfTheSecondController: function () {
    sap.ui.getCore().getEventBus().publish(
        "SomeChannel",
        "SomeEvent",
        "is called from function of the second controller."
    );
}


1 Comment