Skip to content

Load a component in a route depending on an asynchronous condition #12088

@alexjoverm

Description

@alexjoverm

I'm submitting a ... (check one with "x")

Current behavior
Doesn't seem possible to do it in an easy way without not use framework core stuff

Expected behavior
To be able to determine by an asynchronous condition (a condition that will be resolved later) which component to load in a route.

What is the motivation / use case for changing the behavior?
I'd say the following is a very common behavior expected on any medium size app:

Let's say you have a dashboard (just after you login). You wanna keep 2 different components UserDashboard and AdminDashboard (for not filling your template code with *ngIf), but that condition cannot be resolved immediately because the role comes from an API, so then you cannot "right away" conditionally pass one component or another to a specific route.

This doesn't seem to have an answer that implies not to compile and load a component by yourself.
Please, check out http://stackoverflow.com/questions/39688929/angular-2-how-to-conditionally-load-a-component-in-a-route-asynchronously

  • Angular version: 2.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: routerfeatureIssue that requests a new featurefeature: under considerationFeature request for which voting has completed and the request is now under considerationfreq2: medium

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions