You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lazy loading is a technique used to load modules only when they are needed. This can help reduce the initial load time of the application by loading only the necessary modules.
4081
4083
4084
+
Example of lazy loading in non standalone components:
4085
+
4082
4086
```typescript
4083
4087
import { NgModule } from '@angular/core';
4084
4088
import { BrowserModule } from '@angular/platform-browser';
@@ -4190,12 +4194,68 @@ export class Page2Module {}
4190
4194
<router-outlet></router-outlet>
4191
4195
```
4192
4196
4193
-
Certainly! Let's complete the Angular Router guide with examples for the provided sections:
The Angular Router is a powerful tool that allows you to define navigation paths and routes in your application. It enables you to navigate between different components and views based on the URL path.
4198
4256
4257
+
Example of routing in Angular non standalone components:
4258
+
4199
4259
```typescript
4200
4260
// app.module.ts
4201
4261
import { NgModule } from '@angular/core';
@@ -4294,82 +4354,6 @@ export class UserDetailsComponent {
4294
4354
}
4295
4355
```
4296
4356
4297
-
## Routing Module
4298
-
4299
-
A routing module is a feature module that contains the routes and components related to a specific feature or section of an Angular application. It helps organize the application into smaller, more manageable modules.
4300
-
4301
-
```typescript
4302
-
// app-routing.module.ts
4303
-
import { NgModule } from '@angular/core';
4304
-
import { RouterModule, Routes } from '@angular/router';
4305
-
import { HomeComponent } from './home/home.component';
4306
-
import { AboutComponent } from './about/about.component';
4307
-
4308
-
const routes: Routes = [
4309
-
{
4310
-
path: 'home',
4311
-
component: HomeComponent
4312
-
},
4313
-
{
4314
-
path: 'about',
4315
-
component: AboutComponent
4316
-
}
4317
-
];
4318
-
4319
-
@NgModule({
4320
-
imports: [RouterModule.forRoot(routes)],
4321
-
exports: [RouterModule]
4322
-
})
4323
-
4324
-
export class AppRoutingModule { }
4325
-
```
4326
-
4327
-
```typescript
4328
-
// app.module.ts
4329
-
import { NgModule } from '@angular/core';
4330
-
import { BrowserModule } from '@angular/platform-browser';
4331
-
import { AppRoutingModule } from './app-routing.module';
4332
-
import { AppComponent } from './app.component';
4333
-
import { HomeComponent } from './home/home.component';
4334
-
import { AboutComponent } from './about/about.component';
4335
-
4336
-
@NgModule({
4337
-
declarations: [
4338
-
AppComponent,
4339
-
HomeComponent,
4340
-
AboutComponent
4341
-
],
4342
-
imports: [
4343
-
BrowserModule,
4344
-
AppRoutingModule
4345
-
],
4346
-
providers: [],
4347
-
bootstrap: [AppComponent]
4348
-
})
4349
-
4350
-
export class AppModule { }
4351
-
```
4352
-
4353
-
```html
4354
-
<!-- app.component.html -->
4355
-
<nav>
4356
-
<a routerLink="/home">Home</a>
4357
-
<a routerLink="/about">About</a>
4358
-
</nav>
4359
-
4360
-
<router-outlet></router-outlet>
4361
-
```
4362
-
4363
-
```html
4364
-
<!-- home.component.html -->
4365
-
<h1>Home Component</h1>
4366
-
```
4367
-
4368
-
```html
4369
-
<!-- about.component.html -->
4370
-
<h1>About Component</h1>
4371
-
```
4372
-
4373
4357
## Route Parameters
4374
4358
4375
4359
Route parameters are used to pass data to a route in Angular. They allow you to create dynamic routes that can be customized based on user input or other factors. Route parameters are defined in the route configuration and can be accessed in the component associated with the route.
0 commit comments