Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to achieve Dynamic page load in new Version ? #54

Closed
AsrarMemon opened this issue Mar 26, 2018 · 4 comments
Closed

how to achieve Dynamic page load in new Version ? #54

AsrarMemon opened this issue Mar 26, 2018 · 4 comments

Comments

@AsrarMemon
Copy link

I have added router-outlet in in my html code as follows:

<GridLayout rows="*, auto" columns="*" class="page">
    <Pager #pager [pagesCount]="numItems" [selectedIndex]="currentPagerIndex" (selectedIndexChanged)="onIndexChanged($event)" class="pager">
        <StackLayout height="100%">
            <router-outlet height="100%"></router-outlet>
        </StackLayout>
        <StackLayout height="100%">
            <router-outlet name="Graph"></router-outlet>
        </StackLayout>
        <StackLayout height="100%">
            <router-outlet name="DataList"></router-outlet>            
        </StackLayout>
    </Pager>
</GridLayout>

And routing elements as follows:

{
        path: "DetailScreen", component: DetailViewComponent, children: [
          //DetailScreen1 child Components
          { path: "", component: DatalistingComponent, outlet: "DataList" },
          { path: "", component: GraphComponent, outlet: "Graph" },
          { path: "", component: OverviewComponent },
        ]
      },

i known 3 + version uses templates

how to achieve Dynamic page load in 3 + version ?

@triniwiz
Copy link
Owner

This is similar to your previous issue

@AsrarMemon
Copy link
Author

can you please give me a help about how can i Dynamic page load in new version ?

@triniwiz
Copy link
Owner

You can try the following

items = [1, 2, 3];
    public templateSelector = (item: any, index: number, items: any) => {
        return index % 2 === 0 ? 'even' : 'odd';
        if (index === 0) {
            return 'first';
        } else if (index === 1) {
            return 'second';
        } else if (index === 2) {
            return 'third';
        }
    };
<Pager [items]="items" [itemTemplateSelector]="templateSelector">

    <ng-template pagerTemplateKey="first" let-i="index" let-item="item">
        <StackLayout height="100%">
            <router-outlet height="100%"></router-outlet>
        </StackLayout>
    </ng-template>

    <ng-template pagerTemplateKey="second" let-i="index" let-item="item">
        <StackLayout height="100%">
            <router-outlet name="Graph"></router-outlet>
        </StackLayout>
    </ng-template>

    <ng-template pagerTemplateKey="third" let-i="index" let-item="item">
        <router-outlet name="DataList"></router-outlet>
    </ng-template>

</Pager>

@AsrarMemon
Copy link
Author

Hello,

Thank you so much :) it's working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants