0
0
Angularframework~5 mins

Defining routes array in Angular - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the routes array in Angular?
The routes array defines the paths and their corresponding components for navigation in an Angular app. It tells Angular which component to show when a user visits a specific URL.
Click to reveal answer
beginner
How do you define a simple route for a HomeComponent with path 'home'?
You add an object like { path: 'home', component: HomeComponent } inside the routes array.
Click to reveal answer
beginner
What does the empty string path ('') represent in the routes array?
It represents the default or root path of the app, usually shown when the user visits the base URL.
Click to reveal answer
intermediate
How can you define a route that redirects from one path to another?
Use an object with path, redirectTo, and pathMatch properties, like { path: '', redirectTo: 'home', pathMatch: 'full' }.
Click to reveal answer
intermediate
Why is the order of routes in the routes array important?
Angular matches routes in order. More specific routes should come before less specific ones to avoid incorrect matches.
Click to reveal answer
What property in a route object specifies which component to display?
Apath
BredirectTo
Ccomponent
DloadChildren
How do you define a route that redirects from '' to 'home'?
A{ path: '', redirectTo: 'home', pathMatch: 'full' }
B{ path: '', loadChildren: 'home.module' }
C{ path: 'home', redirectTo: '' }
D{ path: '', component: HomeComponent }
What does the 'pathMatch: "full"' option mean in a redirect route?
AMatch the full URL path exactly
BMatch any part of the URL
CIgnore the URL path
DMatch only the first segment
Where should you place wildcard routes (like '**') in the routes array?
AIn the middle
BAt the end
CAt the beginning
DAnywhere
Which Angular module uses the routes array to configure routing?
ABrowserModule
BHttpClientModule
CFormsModule
DRouterModule
Explain how to define a routes array in Angular and what each route object needs.
Think about how Angular knows which component to show for a URL.
You got /4 concepts.
    Describe why the order of routes in the routes array matters and give an example.
    Consider what happens if a wildcard route is first.
    You got /3 concepts.