TypeScript: What does "rootPage: Type = TabsPage;" mean


rootPage: Type = TabsPage;

I just looked at typescript project and came across initialization page members. Couldn’t find any explanation what this construct mean. Can anyone help?




I believe it correlates to a variable “rootPage” is a type of component “TabsPage.”


I’m afraid it’s not that easy.
Following things i tried:

rootPage: TabsPage;

passes compiler, but didn’t construct page.

Next try: initialize member in constructor: this.rootPage = new TabsPage();
Same result as before.

My background is c++, c#. So this are the pattern i tried.

May be a little bit more context will help to understand the problem:

export class MyApp {
    rootPage: Type = TabsPage;

    constructor(platform:Platform) {
        // this.rootPage = new TabsPage();

This is working and i don’t know why.

Regards Steffen


Well Type in an Interface component imported from angular 2. I would review there docs about it listed below. If you import Type from angular 2.

import {Type} from ‘angular2/core’;

<ion-nav id="nav" [root]="rootPage"></ion-nav>

then if you use rootPage: Type = TabsPage; that should default the component without using the constructor. If you want use in the constructor try this.rootPage = TabsPage;



May be your are on right direction with angular2.
Still haven’t found any explanation for this syntax.

this.rootPage = TabsPage;

didn’t work. You can not assign a type to variable.



Got it.

rootPage is of type Type (angular2) and is initialized with Type TabsPage. Simple, if you see Type as Type.
THX @El_Dee565! You brought me to right direction.