Navigation and Routing Basics Flashcards

1
Q

Selector property is only required if

A

component will be nested within another component

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

What Router module does?

A

Registers the router service. Declares the router directives. Exposes configured routes.

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

Route is defined

A

by route definitions

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

Router link directive is an

A

attribute directive.

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

When a route is activated associated component is displayed. But where?

A

By directive router-outlet’. Component is displayed inside.

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

What to do to pass parameters to a route?

A

Add parameters to route. Add router link to anchor tag and add values to the link parameters array. First value is string path of the route. Second value is for the route parameter. When route composes the URL it uses the parameter.

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

To get paramter from URL

A

Use ActivatedRoute service do get parameter.

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

Reading parameters from route can be done in two ways.

A

One, if route parameter doesn’t change - use snapshot.paramMap.
Second, use observable to read parameters if they change - use paramMap…

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

what is ? in product?.name

A

Safe navigation operator.. like in c#

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

How to activate a route with code?

A

Use Router service. The method is .navigate([‘/products’]);

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

What types of Route Guards there are

A

CanActivate - guard navigation to a route
CanDeactivate - guard navigation from a foute
Resolve - Pre-fetch data before activating a route
CanLoad - Prevent asynchronous routing

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

What is a route guard

A

A service. Use @Injectable

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

How to use the route guard

A

Add the guard to the route in the route definitions

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

Angular supports union of types or passing/returning multiple types at ones.

A

True story.

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