cancel
Showing results for 
Search instead for 
Did you mean: 

Router Initialization not working in UI5

Deepak_Diwakar
Newcomer

Hi,

I initialized my router using following code in component.js

 

UIComponent.prototype.init.apply(this, arguments);
this.getRouter().initialize();
 
The above code results in following error
The class 'sap.m.routing.Router' was accessed via globals. Retrieving routing classes via globals is deprecated and a result of synchronous Component creation, please use the asynchronous sap.ui.core.Component.create() factory instead. -

Accepted Solutions (0)

Answers (1)

Answers (1)

72593028
Discoverer
0 Kudos

Hi Deepak,

If your getting the output please ignore the issue But as per sap suggested if any functionality is deprecated we have to use latest code.

Please use below code in your index.html to create a component container. This will solve your issue.

 

sap.ui.core.Component.create({
    name: 'your component name',  like - po.application.test
    manifestFirst: true,
    async : true
}).then(function(oComponent){
    // console.log("Component created:", oComponent);
    var oComponentContainer = new sap.ui.core.ComponentContainer({
        component: oComponent
    });
    oComponentContainer.placeAt("content");
        }).catch(function (oError) {
          console.error("Error during component creation:", oError);
       });
 
Best Regards,
Thulasiram