Low Orbit Flux Logo 2 D

Angular Interview Questions

In this article, we are going to go over various levels of complexity within the Angular framework by answering some questions that are commonly asked during interviews.

What are some lifecycle hooks available within Angular and, as you identify them, provide further details about each one?

What is the difference between an observable and a promise?

What are the three types of directives used in Angular?

How does a component share values with its child components?

Values can be shared from the parent component to the child component via @Input() properties or by having a shared service that maintains a state that can be changed by both components.

How does a component share values with its parent component?

Values can be either emitted by the child component by leveraging the @Output() properties, shared via a shared service, and can be set via the @ViewChild() property within the parent component.

What are the types of files generally used to create an Angular component?

Angular components generally consist of a template, stylesheet, testing, and scripting file. The template file consists of the html code along with angular attributes and directives used to render the component. The stylesheet controls how the component will styled via CSS. The Testing, or spec file, contains the unit tests for the component. Finally, the scripting file contains the lifecycle hooks and data operations used for the component. The only required file to render an Angular component is the scripting file, which may also contain the styles and html used to render the component.

What is Angular Material?

Angular Material is a component library created by Google to provide a way for developers to create a consistent look and feel for their applications. Angular Material is based on Material Design, which creates the principals to generate a modern, and responsive, web application.

What is Angular CDK?

Angular CDK, or Component Dev Kit, is a set of behavior primitives that can be used to build UI components. Angular Material leverages the CDK improve the accessibility of its components. While Angular Material provides styled UI Components, the CDK provides a base to get started with in creating your own UI components.

What is ElectronJS and how does it related to Angular?

ElectronJS is a framework built to take a web application and run it as a desktop application across multiple platforms. With ElectronJS you can easily take your existing Angular application and create a desktop application to distribute to your users. Some examples of this include Visual Studio Code and Slack.

What is an async pipe and how is it used?

An async pipe is a pipe used within an Angular template to subscribe to an observable or promise, and return the latest value as it is emitted. When the value gets emitted by the observable or promise, the pipe marks the component to be checked for changes which in turn, updates the UI.

What is a service in Angular?

A service is used to provide common functionality between various components and modules. Services give users the ability to take duplicated code and put it in a place that is accessible to various components. This includes utility tasks, basic state management, and API requests for data.

What is state management and provide some examples?

State management is a way for the UI to have a data store that is accessible to various parts of the application. It can be as basic as a simple BehaviorSubject within a service class that is read and set from various components, or it can be as complicated as an external framework such as NGRX. Frameworks, like NGRX, give Angular developers a way to store data in a database like fashion that can be read from multiple parts of the application.

What are Http Interceptors in Angular?

Http Interceptors are services that are used to inspect and manipulate request and response data sent to and from the API and Angular application. General use cases for an Http Interceptor would include sending along an api key or authorization token within the request headers.

What is dependency injection?

Dependency injection is a design pattern used to allow a single class to leverage various versions of a subclass. If designed properly, it would give the developer the ability to swap out service classes in an Angular application to either perform data operations differently, or to leverage a separate data source.