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

前端 未结 6 738
花落未央
花落未央 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条回答
  •  Happy的楠姐
    2021-01-31 11:04

    I advice you make use of navigating programatically using the router's navigate method . So you list all the posible routes in the router file .Then in your component you call router.navigate() based on the specific case .

提交回复
热议问题