0% found this document useful (0 votes)
8 views27 pages

angular__1725463483

This document provides a comprehensive overview of key Angular concepts and interview questions, including differences between ngIf and ngFor, the purpose of decorators like @Input and @Output, and the role of services and lazy loading. It also covers advanced topics such as Reactive Programming, Angular Router, and Dependency Injection, along with performance optimization techniques. The information is structured to aid in preparation for Angular interviews, highlighting essential features and best practices.

Uploaded by

r.raniaammari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views27 pages

angular__1725463483

This document provides a comprehensive overview of key Angular concepts and interview questions, including differences between ngIf and ngFor, the purpose of decorators like @Input and @Output, and the role of services and lazy loading. It also covers advanced topics such as Reactive Programming, Angular Router, and Dependency Injection, along with performance optimization techniques. The information is structured to aid in preparation for Angular interviews, highlighting essential features and best practices.

Uploaded by

r.raniaammari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Some questions to prepare you for your

Angular Interview

let’s get started

Find more articles


https://medium.com/@drissi.dalanda8
What is the difference between ngIf
and ngFor ?

ngIf: Conditionally includes or excludes an


element based on a boolean expression.

ngFor: Iterates over a list (array) and generates


an element for each item.

dalanda-drissi
What are @Input and @Output
decorators in Angular?

@Input : Allows a parent component to pass data


to a child component..

@Output: Allows a child component to emit


events to a parent component using an
EventEmitter.

dalanda-drissi
What are Angular Services?

Services are singleton classes that provide shared


data, logic, or functions across components,
promoting code reusability and separation of
concerns.

dalanda-drissi
What is Lazy Loading in Angular?

Lazy loading delays the loading of a module until it's


needed, improving application performance by
reducing initial load time.

dalanda-drissi
What are Pipes in Angular?

Pipes transform data for display in templates (e.g.,


formatting dates or numbers). Custom pipes can be
created for custom transformations.

dalanda-drissi
What is Reactive Programming in
Angular with RxJS?

Reactive programming uses Observables to handle


asynchronous operations and events, allowing for
more manageable and declarative code.

dalanda-drissi
What is Angular Router, and how
does it work?

Angular Router enables navigation between different


views or pages of an application. It uses routes defined
in the app-routing.module.ts file, which maps URL
paths to components.

dalanda-drissi
What is the purpose of Angular's
ngOnInit lifecycle hook?

ngOnInit is a lifecycle hook that is called once after the


component's data-bound properties are initialized. It
is commonly used for initializing component data.

dalanda-drissi
How do you pass data between
components in Angular?

Data can be passed between components using


@Input for parent-to-child communication, @Output
with EventEmitter for child-to-parent communication,
and services for sibling or unrelated components.

dalanda-drissi
What is the difference between
ViewChild and ContentChild?

ViewChild queries elements in the component's view,


while ContentChild queries elements projected into
the component via <ng-content>.

dalanda-drissi
What is Angular Universal?

Angular Universal is a technology for server-side


rendering (SSR) that allows Angular applications to be
rendered on the server, improving performance and
SEO.

dalanda-drissi
What is Dependency Injection (DI)
in Angular?

Dependency Injection is a design pattern in Angular


that allows the injection of services or dependencies
into components, making the code modular, reusable,
and easier to test.

dalanda-drissi
How do you handle errors in HTTP
requests in Angular?

Use the .catchError operator in RxJS to handle errors in


HTTP requests made with HttpClient.

dalanda-drissi
What is the difference between
Reactive Forms and Template-
Driven Forms?

Reactive Forms are more flexible and scalable,


created using FormControl and FormGroup in
TypeScript. Template-Driven Forms rely on directives
in the template (ngModel) and are simpler but less
scalable.

dalanda-drissi
How do you optimize an Angular
application for better performance?

Use lazy loading, change detection strategy (OnPush),


optimize template bindings, use trackBy with ngFor,
and minimize bundle sizes with AOT and tree shaking.

dalanda-drissi
What is a Resolver in Angular?

A resolver is a service that fetches data before


navigating to a route, ensuring the required data is
ready when the component loads.

dalanda-drissi
What is the difference between
Observable and Promise in Angular?

Observable is lazy, can handle multiple values over


time, and is cancellable. Promise is eager, handles a
single future value, and is not cancellable.

dalanda-drissi
What are structural directives in
Angular? Name a few.

Structural directives alter the DOM layout by adding or


removing elements. Examples include *ngIf, *ngFor,
and *ngSwitch.

dalanda-drissi
What are Template Reference
Variables in Angular?

Template Reference Variables, declared with #, are


used to access DOM elements and component
instances directly in the template.

dalanda-drissi
What are Angular Guards, and what
are they used for?

Angular Guards (CanActivate, CanDeactivate, etc.)


control navigation and access to routes based on
specific conditions, enhancing security and user
experience.

dalanda-drissi
What is the purpose of NgZone in
Angular?

NgZone enables Angular to run change detection


outside of the Angular zone, optimizing performance
by limiting unnecessary checks.

dalanda-drissi
What is trackBy in ngFor, and why is it
used?

trackBy optimizes rendering in ngFor by tracking items


with a unique identifier, preventing re-rendering of
unchanged items and improving performance.

dalanda-drissi
What is the difference between
@Injectable and @Component?

@Injectable marks a class as available for


dependency injection, while @Component marks a
class as an Angular component and associates it with
a template.

dalanda-drissi
What are HttpInterceptors in Angular?

HttpInterceptors are part of Angular's HttpClient


module that allow developers to modify outgoing HTTP
requests or incoming responses, typically used for
adding headers or handling errors.

dalanda-drissi
What is ngModel and how does it work
in Angular?

ngModel is a directive used for two-way data binding


in template-driven forms. It binds input, select,
textarea, etc., to a property in the component's class.

dalanda-drissi
What is an Injector in Angular?

An Injector is a service locator that provides instances


of services or dependencies. It is part of Angular's
dependency injection system, creating and managing
dependencies

dalanda-drissi

You might also like