The Angular Routing docs mention component instance creation, component instance activation, and route activation.
The docs do not explain the differences of these co
What is the difference between instance creation and instance activation?
Instantiating means creating an instance of a route (ActivateRoute) or component. Activating of a route means attaching it to the router-outlet directive. Activating of a component means attaching it to the DOM. Routes and components are activated using activateWith function of a router-outlet directive.
Let's see some examples. Suppose you have the following routes:
{
path: 'a',
component: AComponent,
children: [
{ path: 'b', component: BComponent },
{ path: ':name', component: DComponent }
]
}
Now you navigate to a/b.
The router will:
{ path: 'a', component: AComponent, children: [] } route{ path: 'b', component: BComponent } routerouter-outlet locationsAComponent and BComponent using this approachAComponent and BComponent by adding them to DOMNow you navigate to a/n1.
The router will:
a - { path: 'a', component: AComponent, children: [] } route (no instantiation or activation){ path: ':name', component: DComponent } route{ path: ':name', component: DComponent } routeAComponent instance (no instantiation or activation)DComponent instanceDComponent by attaching it to the router-outlet in AComponent viewNow you navigate to a/n2.
The router will:
a - { path: 'a', component: AComponent, children: [] } route (no instantiation or activation)n2 - { path: ':name', component: DComponent } route (no instantiation or activation)n2 activated routeDComponent instance (no instantiation or activation)