Angular Interview questions


Total available count: 96
Subject - JavaScript Frameworks
Subsubject - Angular

What is router state?

RouterState is a tree of activated routes. Every node in this tree knows about the "consumed" URL segments, the extracted parameters, and the resolved data. You can access the current RouterState from anywhere in the application using the Router service and the RouterState property as below.

@Component({templateUrl:'template.html'})
class MyComponent {
  constructor(router: Router) {
    const state: RouterState = router.routerState;
    const root: ActivatedRoute = state.root;
    const child = root.firstChild;
    const id: Observable<string> = child.params.map(p => p.id);
    //...
 }
}

 




Next 5 interview question(s)

1
What are active router links?
2
What are router links?
3
What is router outlet?
4
What are the router imports?
5
What is the purpose of base href tag?