Skip to content

Commit 3906ac1

Browse files
authored
Merge branch 'main' into sponsorcard
2 parents 08d6a32 + 36a1f41 commit 3906ac1

File tree

235 files changed

+16091
-724
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+16091
-724
lines changed

blog/Introduction to Cryptography and Cyber security.md renamed to blog/introduction-to-cryptography-and-cyber-security.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: 'Cryptography and Its Use in Cyber Security'
2+
title: "Cryptography and Its Use in Cyber Security"
33
sidebar_label: Cryptography and Cyber Security
44
authors: [pujan-sarkar]
55
tags: [cryptography, cyber security, encryption, technology]
@@ -81,4 +81,3 @@ Zero-knowledge proofs enable one party to prove to another that a statement is t
8181
## Conclusion
8282

8383
Cryptography is a cornerstone of cyber security, providing the means to protect data and maintain privacy in an increasingly interconnected world. As technology advances and new threats emerge, the field of cryptography will continue to evolve, offering innovative solutions to ensure the security and integrity of our digital lives. By understanding and implementing cryptographic techniques, individuals and organizations can safeguard their information and build a secure future.
84-
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
id: lesson-1
3+
title: "Advanced Forms in Angular"
4+
sidebar_label: Advanced Forms
5+
sidebar_position: 1
6+
description: "Advanced Forms in Angular"
7+
tags: [courses,Advanced-level,Form,Introduction]
8+
---
9+
10+
Angular's reactive forms provide powerful tools for creating complex form structures and handling user input efficiently. Here are some advanced concepts you can leverage in Angular forms.
11+
12+
#### Dynamic Forms
13+
14+
Dynamic forms allow you to create forms whose structure can change at runtime based on user actions or external data.
15+
16+
1. **Creating Dynamic Forms**:
17+
```typescript
18+
import { FormBuilder, FormGroup, FormArray } from '@angular/forms';
19+
import { Component } from '@angular/core';
20+
21+
@Component({
22+
selector: 'app-dynamic-form',
23+
templateUrl: './dynamic-form.component.html',
24+
})
25+
export class DynamicFormComponent {
26+
form: FormGroup;
27+
28+
constructor(private fb: FormBuilder) {
29+
this.form = this.fb.group({
30+
items: this.fb.array([])
31+
});
32+
}
33+
34+
get items(): FormArray {
35+
return this.form.get('items') as FormArray;
36+
}
37+
38+
addItem() {
39+
const item = this.fb.control('');
40+
this.items.push(item);
41+
}
42+
43+
removeItem(index: number) {
44+
this.items.removeAt(index);
45+
}
46+
}
47+
```
48+
49+
2. **Dynamic Form Template**:
50+
```html
51+
<form [formGroup]="form">
52+
<div formArrayName="items">
53+
<div *ngFor="let item of items.controls; let i = index">
54+
<input [formControlName]="i" placeholder="Item"/>
55+
<button (click)="removeItem(i)">Remove</button>
56+
</div>
57+
</div>
58+
<button (click)="addItem()">Add Item</button>
59+
</form>
60+
```
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
id: lesson-2
3+
title: "Custom Form Controls"
4+
sidebar_label: Form Controls
5+
sidebar_position: 2
6+
description: "Custom Form Controls"
7+
tags: [courses,Advanced-level,Form Controls,Introduction]
8+
---
9+
10+
11+
12+
Creating custom form controls allows you to encapsulate complex form logic and UI in reusable components.
13+
14+
1. **Creating a Custom Control**:
15+
```typescript
16+
import { Component, forwardRef } from '@angular/core';
17+
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
18+
19+
@Component({
20+
selector: 'app-custom-input',
21+
template: `<input [(ngModel)]="value" (ngModelChange)="onChange($event)" />`,
22+
providers: [
23+
{
24+
provide: NG_VALUE_ACCESSOR,
25+
useExisting: forwardRef(() => CustomInputComponent),
26+
multi: true
27+
}
28+
]
29+
})
30+
export class CustomInputComponent implements ControlValueAccessor {
31+
value: string;
32+
33+
onChange = (value: string) => {};
34+
onTouched = () => {};
35+
36+
writeValue(value: string): void {
37+
this.value = value;
38+
}
39+
40+
registerOnChange(fn: any): void {
41+
this.onChange = fn;
42+
}
43+
44+
registerOnTouched(fn: any): void {
45+
this.onTouched = fn;
46+
}
47+
}
48+
```
49+
50+
2. **Using Custom Control in a Form**:
51+
```html
52+
<form [formGroup]="form">
53+
<app-custom-input formControlName="customField"></app-custom-input>
54+
</form>
55+
```
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
id: lesson-3
3+
title: "Form Arrays"
4+
sidebar_label: Async
5+
sidebar_position: 3
6+
description: "Form Arrays"
7+
tags: [courses,Advanced-level,Form Arrays,Introduction]
8+
---
9+
10+
11+
Form arrays are used to manage an array of form controls or groups, allowing you to build complex forms.
12+
13+
1. **Creating a Form Array**:
14+
```typescript
15+
import { FormArray, FormGroup, FormBuilder } from '@angular/forms';
16+
17+
this.form = this.fb.group({
18+
users: this.fb.array([
19+
this.fb.group({ name: '', age: '' }),
20+
this.fb.group({ name: '', age: '' })
21+
])
22+
});
23+
```
24+
25+
2. **Template for Form Array**:
26+
```html
27+
<form [formGroup]="form">
28+
<div formArrayName="users">
29+
<div *ngFor="let user of form.get('users').controls; let i = index">
30+
<div [formGroupName]="i">
31+
<input formControlName="name" placeholder="Name"/>
32+
<input formControlName="age" placeholder="Age"/>
33+
</div>
34+
</div>
35+
</div>
36+
</form>
37+
```
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
id: lesson-4
3+
title: "Advanced Form Validation"
4+
sidebar_label: Form Validation
5+
sidebar_position: 4
6+
description: "Advanced Form Validation"
7+
tags: [courses,Advanced-level,Form Validation,Introduction]
8+
---
9+
10+
11+
12+
Advanced validation techniques allow you to implement complex validation rules for your forms.
13+
14+
1. **Custom Validators**:
15+
```typescript
16+
import { AbstractControl, ValidatorFn } from '@angular/forms';
17+
18+
export function ageValidator(min: number): ValidatorFn {
19+
return (control: AbstractControl): { [key: string]: any } | null => {
20+
const valid = control.value >= min;
21+
return valid ? null : { 'ageInvalid': { value: control.value } };
22+
};
23+
}
24+
```
25+
26+
2. **Using Custom Validators**:
27+
```typescript
28+
this.form = this.fb.group({
29+
age: ['', [Validators.required, ageValidator(18)]]
30+
});
31+
```
32+
33+
3. **Asynchronous Validators**:
34+
Asynchronous validators are useful for checking values against a remote server.
35+
```typescript
36+
import { Observable, of } from 'rxjs';
37+
import { delay } from 'rxjs/operators';
38+
39+
export function usernameValidator(): AsyncValidatorFn {
40+
return (control: AbstractControl): Observable<ValidationErrors | null> => {
41+
const forbidden = control.value === 'admin';
42+
return of(forbidden ? { 'usernameForbidden': { value: control.value } } : null).pipe(delay(1000));
43+
};
44+
}
45+
```
46+
47+
4. **Using Async Validators**:
48+
```typescript
49+
this.form = this.fb.group({
50+
username: ['', { validators: [Validators.required], asyncValidators: [usernameValidator()] }]
51+
});
52+
```
53+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"label": "Advanced Forms",
3+
"position": 2,
4+
"link": {
5+
"type": "generated-index",
6+
"description": "Learn to Advanced Forms."
7+
}
8+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
id: lesson-4
3+
title: "Custom Route Strategies"
4+
sidebar_label: Custom Route
5+
sidebar_position: 4
6+
description: "Custom Route Strategies"
7+
tags: [courses,Advanced-level,Custom Route,Introduction]
8+
---
9+
10+
11+
Custom route strategies allow you to implement advanced routing behaviors that suit specific application needs.
12+
13+
1. **Creating a Custom Route Strategy**:
14+
```typescript
15+
import { RouteReuseStrategy, DetachedRouteHandle } from '@angular/router';
16+
17+
export class CustomRouteReuseStrategy implements RouteReuseStrategy {
18+
storedRouteHandles: { [key: string]: DetachedRouteHandle } = {};
19+
20+
shouldDetach(route: ActivatedRouteSnapshot): boolean {
21+
return true; // Modify as needed
22+
}
23+
24+
store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle): void {
25+
this.storedRouteHandles[route.routeConfig.path] = handle;
26+
}
27+
28+
shouldAttach(route: ActivatedRouteSnapshot): boolean {
29+
return !!this.storedRouteHandles[route.routeConfig.path];
30+
}
31+
32+
retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle {
33+
return this.storedRouteHandles[route.routeConfig.path];
34+
}
35+
36+
shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean {
37+
return future.routeConfig === curr.routeConfig;
38+
}
39+
}
40+
```
41+
42+
2. **Providing the Custom Strategy**:
43+
Update your `AppModule` to use the custom route strategy.
44+
45+
```typescript
46+
import { NgModule } from '@angular/core';
47+
import { RouterModule, RouteReuseStrategy } from '@angular/router';
48+
49+
@NgModule({
50+
imports: [RouterModule.forRoot(routes)],
51+
providers: [{ provide: RouteReuseStrategy, useClass: CustomRouteReuseStrategy }]
52+
})
53+
export class AppRoutingModule {}
54+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
id: lesson-3
3+
title: "Nested Routes"
4+
sidebar_label: Nested Routes
5+
sidebar_position: 3
6+
description: "Nested Routes"
7+
tags: [courses,Advanced-level,Nested Routes,Introduction]
8+
---
9+
10+
11+
12+
Nested routes allow you to create hierarchical route structures, making your application more organized and maintainable.
13+
14+
1. **Defining Nested Routes**:
15+
```typescript
16+
const routes: Routes = [
17+
{
18+
path: 'products',
19+
component: ProductsComponent,
20+
children: [
21+
{ path: '', component: ProductListComponent },
22+
{ path: ':id', component: ProductDetailComponent }
23+
]
24+
}
25+
];
26+
```
27+
28+
2. **Using Router Outlet**:
29+
In the `ProductsComponent` template, include a `<router-outlet>` for nested views.
30+
31+
```html
32+
<h1>Products</h1>
33+
<router-outlet></router-outlet>
34+
```
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
id: lesson-2
3+
title: "Route Resolvers"
4+
sidebar_label: Route Resolvers
5+
sidebar_position: 2
6+
description: "Route Resolvers"
7+
tags: [courses,Advanced-level,Route Resolvers,Introduction]
8+
---
9+
10+
Route resolvers are a powerful way to fetch data before the route loads. This ensures the data is available when the component is initialized.
11+
12+
1. **Using a Resolver**:
13+
```typescript
14+
const routes: Routes = [
15+
{
16+
path: 'dashboard',
17+
component: DashboardComponent,
18+
resolve: {
19+
data: DataResolver
20+
}
21+
}
22+
];
23+
```
24+
25+
2. **Accessing Resolved Data**:
26+
```typescript
27+
import { ActivatedRoute } from '@angular/router';
28+
29+
@Component({
30+
selector: 'app-dashboard',
31+
templateUrl: './dashboard.component.html',
32+
})
33+
export class DashboardComponent {
34+
data: any;
35+
36+
constructor(private route: ActivatedRoute) {
37+
this.route.data.subscribe(data => {
38+
this.data = data['data'];
39+
});
40+
}
41+
}
42+
```

0 commit comments

Comments
 (0)