Angular 2: How to conditionally load a Component in a Route asynchronously?

前端 未结 6 636
花落未央
花落未央 2021-01-31 10:39

I\'d like to attach a component to a route asynchronously, given a condition.

The following example, which works (but is asynchronous), loads one compon

6条回答
  •  深忆病人
    2021-01-31 11:09

    Since you will be using one route for either component, one solution is create another component for that route then its template could refer to both components but with an ngIf like below:

    
    
    

提交回复
热议问题