Skip to Content
0

Init function not called in Component.js

Feb 01, 2017 at 03:59 PM

180

avatar image
Former Member

Dear All,

In my plunk below: https://plnkr.co/edit/ksmw5NBh12gImVek2P3C routing not working because Component is not instantiate could you please help me to understand why and how to correct it ?

10 |10000 characters needed characters left characters exceeded
Former Member

Hi Jonathan,

Just my guess. Can you try changing "viewPath" under routing section in manifest.json to

"viewPath": "agoratoolsui5.app",

rather than

"viewPath": "app"
0
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Sai Vellanki Feb 02, 2017 at 01:29 AM
0

Hello Jonathan,

You have placed the init code in metadata, which is not correct. Your component.js code should be like below:

sap.ui.define(['sap/ui/core/UIComponent', "sap/ui/model/json/JSONModel"],
  function(UIComponent, JSONModel) {
    "use strict";

    var Component = UIComponent.extend("agoratoolsui5.Component", {

      metadata: {
        manifest: "json"
      },
      init: function() {
        // call the init function of the parent
        UIComponent.prototype.init.apply(this, arguments);
        this.getRouter().initialize();
        console.log('init router');
      }

    });

  });

Thank you!

Best Regards,

Sai.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 01, 2017 at 09:10 PM
0

Hi Murali,

Thanks for your help, but not working...

Any other idea?

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 02, 2017 at 07:46 AM
0

Hi Sai,

Thanks a lot works now :)

Share
10 |10000 characters needed characters left characters exceeded