Angular 8 Interview Questions and Answers
Ques 11. Explain Angular pipes.
Pipes in Angular are used to transform data before displaying it in the view. Examples include date pipe, currency pipe, and uppercase pipe.
Example:
{{ today | date: 'dd/MM/yyyy' }}
Ques 12. What is the purpose of trackBy in ngFor?
The trackBy function is used in ngFor to improve the performance of rendering by helping Angular identify which items have changed, been added, or been removed in a list.
Example:
*ngFor='let item of items; trackBy: trackByFunction'
Ques 13. Explain Angular routing and how it works.
Angular routing is a mechanism that allows navigation between different components in an Angular application. It works by associating a component with a specific route, and the Angular Router takes care of loading the associated component when the route is activated.
Example:
const routes: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'about', component: AboutComponent },
];
Ques 14. What is Angular template driven forms?
Template-driven forms in Angular are a way to work with forms using directives in the template. The form and its controls are defined in the component's template, and Angular automatically creates and manages the corresponding controls and their data bindings.
Example:
Ques 15. Explain reactive forms in Angular.
Reactive forms in Angular provide a model-driven approach to handling forms. The form controls are created programmatically in the component, and the component is responsible for managing the form's state and behavior.
Example:
this.myForm = this.fb.group({
name: ['', Validators.required],
email: ['', [Validators.required, Validators.email]],
});
Most helpful rated by users: