Node7 - Copy
Node7 - Copy
Introduction to aaass
Angular is a TypeScript-based open-source front-end web framework.
2. Angular Architecture
Modules: @NgModule decorator, organizes app into cohesive blocks.
3. Component Basics
ts
Copy
Edit
@Component({
selector: 'app-hello',
templateUrl: './hello.component.html',
styleUrls: ['./hello.component.css']
})
export class HelloComponent {
name = 'Angular';
}
Selector: Custom HTML tag.
5. Directives
Structural Directives: *ngIf, *ngFor, *ngSwitch
6. Routing
Configure in app-routing.module.ts
ts
Copy
Edit
const routes: Routes = [
{ path: 'home', component: HomeComponent },
{ path: '', redirectTo: '/home', pathMatch: 'full' }
];
Use <router-outlet></router-outlet> in templates.
8. HTTP Client
Import HttpClientModule
ts
Copy
Edit
constructor(private http: HttpClient) {}
getData() {
return this.http.get('https://api.example.com/data');
}
9. Forms
Template-driven: Uses FormsModule, two-way binding.
ts
Copy
Edit
this.form = new FormGroup({
name: new FormControl('', Validators.required)
});
10. Lifecycle Hooks
ngOnInit(): Called after component initialized.
11. Pipes
Format data in templates.
html
Copy
Edit
{{ birthday | date }}
{{ name | uppercase }}
Custom pipe: use @Pipe and implement transform().