Ionic v3 changing default startup page

I want to be able to load pages using my database.

Usually, when we use the pages they are used as component. But when I get the page name in the database its being treated as a string.

For example, in the app.component page we can see this line:

this.rootPage = FirstPage;

But when I load it using my database like this:

this.rootPage = data[0].value;

It shows an error. How do I load it from the database and still treat it as a component?

Currently, I am doing it in a switch statement. It works but its not clean.

Help is appreciated. Thanks!

Apologies in advance for the fact that you’re going to hate this answer, but:

Don’t do this.

Aside from the fact that it makes much of your app opaque to static code analysis, it is antithetical to the way that Angular builds apps behind the scenes and will break in production. Never rely on the string representation of any JavaScript identifiers (which includes class and method names).