Back to notes
How can you start an Angular project and access it in a browser?
Press to flip
Use the command `ng serve` and access the project via `localhost:4200`.
What are the benefits of organizing an Angular application into modules?
Modules promote modularity, reusability, and a clear separation of application concerns.
What are the two approaches for handling forms in Angular?
Template-driven forms and reactive forms.
What is the purpose of Angular's `ngStyle` directive?
The `ngStyle` directive dynamically sets inline styles on an element based on an expression.
Describe the purpose of Angular's `ngFor` directive.
The `ngFor` directive is used to loop through arrays and render list items in the DOM.
List three common RxJS operators used to handle observables in Angular's `HttpClient` module.
`map`, `catchError`, and `switchMap`.
How are custom validators defined in Reactive Forms, and why are they used?
Custom validators are defined as functions that return either `null` for valid controls or an error object for invalid controls, used to implement reusable and dynamic validation logic.
What are the key building blocks of an Angular application?
Components, which include HTML templates, CSS styles, and TypeScript code.
What are route parameters and how are they used in Angular routing?
Route parameters allow capturing dynamic segments in the URL to pass data to components, defined using `:parameterName` in the route path.
Describe the role of `<router-outlet>` in Angular routing.
The `<router-outlet>` directive serves as a placeholder in the DOM where routed components are displayed based on the application's current route.
What command is used to create a new Angular project using Angular CLI?
`ng new <project-name>`
What is the difference between one-way and two-way data binding in Angular?
One-way data binding updates the view from the model (`{{}}` and `[property]`), while two-way data binding (`[(ngModel)]`) allows for synchronization between the model and the view.
How does handling events in Angular work using event binding?
Event binding uses `(event)` syntax to capture user interactions and execute specified methods from the component class when events occur.
What is Angular Dependency Injection (DI), and why is it useful?
DI is a design pattern used to implement IoC by allowing a component's dependencies to be injected at runtime rather than being hardcoded, promoting modularity and testability.
What is the purpose of Angular's `@Component` decorator?
The `@Component` decorator is used to define metadata for the component, including its selector, template, and styles.
Explain how programmatic navigation is achieved in Angular.
Programmatic navigation is achieved using the `Router` service's `navigate` or `navigateByUrl` methods.
Explain how `ngIf` directive works in Angular.
The `ngIf` directive conditionally includes or excludes an element in the DOM based on the evaluation of an expression.
Previous
Next