NG Interview Set I - Routing Questions Flashcards

NG Interview Set I - Routing Questions

1
Q

What is the difference between RouterModule.forRoot() vs RouterModule.forChild()? Why is it important?

A
  • forRoot is a convention for configuring app-wide Router service with routes, whereas forChild is for configuring the routes of lazy-loaded modules
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does loadChildren property work?

A
  • The Router calls it to dynamically load lazy loaded modules for particular routes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When does a lazy loaded module get loaded?

A
  • When its related route is first requested
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How would you use a Route Guard?

A
  • You would implement CanActivate or CanDeactivate and specify that guard class in the route path you’re guarding
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are some different types of RouteGuards?

A
  • CanActivate, CanDeactivate, CanLoad, Resolve, etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How would you intercept 404 errors in Angular 2?

A
  • Can provide a final wildcard path like so: { path: ‘**’, component: PageNotFoundComponent }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

This link doesn’t work. Why? How do I fix it? ` < div routerLink=’ product.id ‘ > < /div > `

A

` < a [routerLink]= ” [’ product.id ’] ” > {{product.id}} < /a > `

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What do route guards return?

A
  • boolean or a Promise/Observable resolving to boolean value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is < router-outlet >for?

A
  • Specifies the place where routes are mounted in the application
How well did you know this?
1
Not at all
2
3
4
5
Perfectly