Information Technology
Angular Interview Questions & Answers
The Angular front-end framework.
Accessibility (a11y) in Angular
All 5 questionsAccessibility means building an app that everyone can use, including people who use screen readers, keyboards only, or have vision or motor difficulties. In Angular this means usin…
The Angular CDK includes a dedicated a11y package with tools like FocusTrap, which keeps keyboard focus inside a dialog while it is open, and LiveAnnouncer, which lets you announce…
You bind ARIA attributes directly in the component template using Angular's attribute binding syntax, describing the role and current state of a custom element so a screen reader c…
- How would you manage keyboard focus properly in an Angular modal dialog to keep it accessible? Advanced
When a modal opens, focus should move into the modal automatically, and it should stay trapped inside the modal while it is open so a keyboard user cannot accidentally tab to conte…
The Angular ESLint plugin can catch some accessibility mistakes right inside your code editor while you type. The axe DevTools browser extension and Lighthouse in Chrome scan a run…
Angular Animations
All 5 questionsThe Angular animations module lets you define smooth transitions between different states of an element, such as fading in or sliding a panel into view. You enable it by importing…
- How do you define a simple fade in animation using the trigger and transition functions in Angular? Intermediate
You define an animation trigger with a name, describe the styles for each state using the state function, and describe how to move between those states using the transition functio…
- How would you animate a list where items can be added or removed, such as a shopping cart? Intermediate
Angular provides special animation functions like query and stagger that let you detect when elements enter or leave a list, and animate each one, such as sliding it out smoothly,…
- How do route transition animations work in Angular, allowing pages to animate as a user navigates? Advanced
You can attach an animation trigger to the element that wraps your router outlet, then use special selectors to detect when a new route enters and the old route leaves, letting you…
You can combine a simple Angular animation trigger with a state that responds to a boolean flag toggled by a mouseenter and mouseleave event, or more simply use plain CSS transitio…
Angular CDK (Component Dev Kit)
All 5 questionsThe Angular CDK, short for Component Dev Kit, provides behavior and utilities for building custom components, such as overlays, drag and drop, and accessibility helpers, without an…
The CDK Drag and Drop module provides directives that let you make any element draggable and any container a valid drop zone, handling the complex logic of tracking drag position,…
The Overlay service creates a floating container attached to the page independent of the normal component layout, letting you position content precisely relative to a trigger eleme…
- What does the CDK's virtual scrolling feature do, and why is it useful for very long lists? Intermediate
Virtual scrolling only renders the items currently visible on screen, plus a small buffer, instead of rendering every single item in a very long list at once. This keeps the page f…
The CDK Layout module provides tools for detecting the current screen size and responding to changes, such as switching between a mobile and desktop layout, using a simple observab…
Angular CLI & Project Structure
All 5 questionsThe Angular CLI is a command line tool that helps you create, build, test, and manage an Angular project without setting up complicated build tools yourself. Running a single comma…
The angular.json file holds the configuration for how your project is built, tested, and served, including things like which files to include in the build, environment specific set…
The CLI provides generate commands, often shortened to g, that create new files following Angular's recommended structure and naming conventions automatically, saving you from manu…
- What is the typical folder structure of a modern Angular project, and what does each main folder contain? Intermediate
The src folder contains your actual application code, with an app folder holding your components, services, and other feature code. An assets folder holds images and static files,…
Running ng build with the production configuration creates an optimized version of your app with smaller file sizes, and tools like the source-map-explorer package let you visualiz…
Angular DevTools & Debugging
All 5 questionsAngular DevTools is a free browser extension for Chrome and Firefox that adds new tabs to your browser's developer tools, letting you inspect your app's component tree, view curren…
The Profiler tab lets you record a session while interacting with your app, then shows a visual chart of exactly how long each component took during every change detection cycle, m…
Common causes include mutating an array or object directly instead of creating a new one when using the OnPush change detection strategy, since Angular only checks for a new refere…
Angular's development build includes source maps, which map the compiled JavaScript back to your original TypeScript files, letting you set breakpoints directly in your real source…
Read the error message carefully from top to bottom, since Angular error messages usually include the exact component name and often a helpful stack trace showing where the problem…
Angular Elements (Web Components)
All 5 questionsAngular Elements let you package an Angular component as a standard web component, called a custom element, which can then be used inside any web page or framework, such as plain H…
- How do you pass data into an Angular Element from outside, such as from plain HTML or JavaScript? Intermediate
You can pass data into an Angular Element using regular HTML attributes, which map to the component's inputs, and Angular Elements automatically converts these attribute values int…
You configure your build to produce a single JavaScript file containing your component along with all of Angular's necessary runtime code, then any website can simply include that…
- What is the difference between using Angular Elements and building a full micro frontend architecture? Intermediate
Angular Elements are best suited for embedding one specific, self contained piece of functionality, like a widget or a small form, into another page or application. A full micro fr…
Imagine a company wants to offer the exact same interactive product configurator on their own Angular based website and also as an embeddable widget on partner websites built with…
Angular Material & UI Component Libraries
All 5 questionsAngular Material is an official component library built by the Angular team, providing ready to use, well tested, and accessible components like buttons, dialogs, and date pickers…
You inject the MatDialog service into your component, and call its open method with the component you want to display inside the dialog. The dialog handles showing itself, dimming…
Angular Material's table component works together with a data source, and you define which columns to display using column definitions in your template, giving you a fully function…
You implement the MatFormFieldControl interface on your custom component, providing the required properties and methods Angular Material expects, letting your custom input work sea…
Other widely used options include PrimeNG, which offers a very large collection of components and several visual themes, and Ng Bootstrap, which brings Bootstrap's popular design s…
Angular Material Theming
All 5 questionsA theme defines the colors, typography, and density used across every Angular Material component in your app. You either use one of the prebuilt themes that ship with Angular Mater…
You define color palettes using Material's color definition functions, choosing specific colors for your primary and accent roles, then pass these into your theme definition, which…
You define two separate theme classes, one for light mode and one for dark mode, and toggle a CSS class on your app's root element based on the user's chosen preference. Angular Ma…
- What is theme density in Angular Material, and how does adjusting it affect the size of components? Advanced
Density controls how compact or spacious Material components appear, letting you shrink padding and sizing across buttons, form fields, and other components uniformly, which is use…
Material 3, Google's newer design system, introduces a more flexible color system based on a single seed color that automatically generates a full, harmonious palette, along with u…
Angular Schematics & Custom Builders
All 5 questionsA schematic is a template based code generator that the Angular CLI uses to create new files, such as components and services, following consistent naming and structure rules. Ever…
You create a new schematic project using the Angular schematics CLI tools, define a rule function that describes what files to create and how to transform them, and package it as a…
A schematic generates or modifies source code files, while a builder actually performs a task using your project's code, such as building it for production, running tests, or deplo…
- How would you use Angular's automatic update schematics to upgrade a project to a new major version? Intermediate
Running ng update with the Angular package name automatically applies migration schematics that update your code to match breaking changes in the new version, such as renaming APIs…
Creating internal schematics helps a company enforce consistent code patterns, folder structures, and best practices automatically across many different teams and projects, reducin…
Angular Security (XSS, Sanitization & CSP)
All 5 questions- What is cross site scripting, often called XSS, and how does Angular protect against it by default? Beginner
Cross site scripting happens when an attacker manages to inject malicious code into a page, which then runs in another user's browser, often stealing information or performing unwa…
The DomSanitizer service lets you explicitly mark a value as safe to use in a specific context, like HTML, a URL, or a style, bypassing Angular's default automatic sanitization. It…
You use a trusted sanitization library, like DOMPurify, to clean the HTML first, removing any dangerous scripts or unsafe attributes, before ever marking the result as trusted usin…
A Content Security Policy is a set of rules, usually sent as an HTTP header from the server, that tells the browser exactly which sources of scripts, styles, and other content are…
Data kept in local storage remains accessible to any JavaScript running on the page, meaning a successful cross site scripting attack could potentially read and steal that token. S…
Angular Signals
All 5 questionsA signal is a wrapper around a value that notifies Angular exactly when that value changes, letting Angular update only the specific parts of the page that actually depend on it. Y…
- What is a computed signal, and how does it automatically stay in sync with the signals it depends on? Intermediate
A computed signal derives its value from one or more other signals, and Angular automatically tracks which signals it reads, recalculating the computed value only when one of those…
- How do you use the effect function with signals to run code whenever a signal's value changes? Intermediate
The effect function lets you run a piece of code automatically whenever any signal it reads inside changes, similar to how a computed signal works, but instead of producing a new v…
Signal inputs let a component receive data from its parent as a signal instead of a plain property, using the input function. This means the component can react to changes just lik…
Signals provide a simpler way to manage values that change over time for many common cases, without needing to understand the broader concepts of RxJS, like subscribing and unsubsc…
Angular Style Guide & Best Practices
All 5 questionsThe official Angular style guide provides recommended conventions for naming files, organizing folders, and structuring components and services consistently. Following it helps a t…
- What is the single responsibility principle and how does it apply to writing Angular components and services? Intermediate
The single responsibility principle means each component or service should do just one clear thing, such as displaying a single piece of information or handling one specific type o…
- Why does the Angular style guide recommend using the OnPush change detection strategy where possible? Intermediate
OnPush tells Angular to only check a component for changes when its inputs actually change by reference, or when an event happens inside it, rather than checking it on every single…
- What are some best practices for structuring a large Angular application with many features? Advanced
Common recommendations include organizing code by feature rather than by file type, keeping shared, reusable code in a dedicated shared module or folder, lazy loading feature areas…
Small, focused components are easier to understand at a glance, easier to test in isolation, and easier to reuse in different parts of an app. A very large component that handles t…
Build, Environments & Deployment
All 5 questionsRunning ng build with the production configuration creates an optimized version of your app, with smaller file sizes and development warnings removed, ready to be uploaded to a rea…
- How do environment files work in Angular, and how do you use different values for development and production? Intermediate
Angular projects typically include separate environment files, such as environment.ts for development and environment.prod.ts for production, each exporting the same variable names…
- What are some popular hosting options for deploying an Angular app, and how do they differ? Intermediate
Firebase Hosting and Netlify are popular choices that make deploying a built Angular app quick and simple, often connecting directly to your code repository and automatically deplo…
A continuous deployment pipeline automatically runs your tests, builds your app, and deploys it to a live server every time new code is pushed to your repository, without anyone ne…
A bundle size budget warns or fails the build if your app's JavaScript files grow beyond a specified size, helping the team catch accidental bloat, such as an unnecessarily large l…
Change Detection
All 5 questionsChange detection is the process Angular uses to check whether any data used in a component's template has changed, and if so, update the actual page to reflect the new values. It r…
The Default strategy checks every component in the app on every change detection cycle, regardless of whether its data actually changed. The OnPush strategy only checks a component…
- Why does mutating an array or object directly sometimes fail to trigger a component update when using OnPush? Intermediate
With OnPush, Angular only checks whether an input's reference has changed, not whether its internal contents have changed. Directly mutating an existing array or object keeps the s…
Traditional Angular relies on Zone.js to automatically detect when something might have changed, such as after any asynchronous operation, then checks the entire app just in case.…
You can inject the ChangeDetectorRef service and call its detectChanges or markForCheck method to tell Angular to check a specific component, which is sometimes necessary when a va…
Components & Templates
All 5 questionsA component is a reusable piece of the user interface, combining a TypeScript class that holds data and logic, an HTML template that describes what appears on screen, and optionall…
You use double curly braces, called interpolation, to display the value of a property directly inside your HTML template. Angular automatically keeps this displayed value in sync w…
- How do standalone components change the way you organize and use components in Angular? Intermediate
Standalone components declare their own dependencies, like which directives or other components they use, directly within the component itself using the imports array, removing the…
Newer versions of Angular provide the at if block, a built in control flow syntax that lets you show or hide content based on a condition directly in your template, replacing the o…
You mark a class property with the Input decorator, or use the newer input function, letting a parent component pass a value down through an attribute in the template, which the ch…
Content Projection (ng-content)
All 5 questionsContent projection lets a component accept and display content passed in by whatever uses it, similar to how a picture frame can hold any picture you place inside it. You add an ng…
- How would you use multiple ng-content slots to project content into different specific locations within a component? Intermediate
You add a select attribute to each ng-content tag, matching a specific CSS selector, letting content marked with a matching attribute or class be projected into that exact slot, ra…
ng-template defines a piece of template content that is not rendered immediately by default, and a component can accept it as an input, deciding exactly when and how to render it,…
- How would you check whether any content was actually projected into a component using ng-content? Intermediate
You can use the ContentChild decorator to get a reference to projected content, and check whether it exists after the view has initialized, letting you conditionally render fallbac…
A reusable alert box component can use content projection to display any message passed into it, whether that message is plain text, a link, or even another small component, withou…
Data Binding
All 5 questionsAngular supports interpolation for displaying a value in text, property binding for setting an element's property, event binding for responding to user actions, and two way binding…
You wrap an event name in parentheses inside your template, and set it equal to a method on your component class, which Angular calls automatically whenever that specific event, li…
Two way binding is really a combination of a property binding and an event binding happening together. The square brackets set the input's value from your component's property, whi…
You define a regular Input property and a matching Output property whose name is the input's name followed by the word Change, emitting the new value whenever it changes. Angular t…
- How does attribute binding differ from property binding, and when do you actually need to use it? Intermediate
Property binding sets a property directly on the underlying DOM element object, which works for most common cases. Attribute binding, using the attr prefix, is needed specifically…
Dependency Injection Providers & Injection Tokens
All 5 questionsA provider tells Angular's dependency injection system how to create a specific value or service when something asks for it. Most commonly this is just the class itself, but a prov…
- What is an injection token in Angular, and when would you need one instead of just injecting a class? Intermediate
An injection token is used when you want to inject something that is not a class, such as a plain configuration object or a primitive value, since Angular's dependency injection no…
- How does the useFactory provider option let you create a service with more complex setup logic? Advanced
The useFactory option lets you provide a function that Angular calls to create the actual value, rather than just instantiating a class directly, useful when creating a service req…
useClass tells Angular to create a brand new instance of a different class when something asks for the original one, useful for swapping implementations, such as during testing. us…
Setting providedIn to root tells Angular to make this service available application wide, using a single shared instance, without needing to manually list it in any component's or…
Directives
All 5 questionsA directive is a class that adds behavior to an element in your template. Component directives are directives with their own template. Structural directives, like the older asteris…
You create a class decorated with the Directive decorator, specifying a selector that matches the attribute you want to use in templates, then use dependency injection to get a ref…
- How does the HostListener decorator let a directive respond to events on its host element? Intermediate
HostListener lets you attach an event listener directly to the element a directive is applied to, without needing to manually add event bindings in a template, making it useful for…
You inject a TemplateRef, representing the content the directive is applied to, and a ViewContainerRef, representing where that content can be inserted, then use createEmbeddedView…
- What is the ngFor structural directive used for, and how does the newer at for syntax compare to it? Beginner
ngFor, and its newer replacement the at for control flow block, repeats a piece of template content once for every item in a list, letting you display a collection of data such as…
End to End Testing with Cypress & Playwright
All 5 questions- What is end to end testing and how is it different from the unit tests Angular sets up by default? Beginner
End to end testing runs your actual app in a real browser and simulates a real user's actions, like clicking buttons and filling out forms, checking that entire flows work correctl…
- How would you set up Cypress in an Angular project to write your first end to end test? Intermediate
You install Cypress as a development dependency, run its setup command to generate a starter configuration, then write test files describing the user flows you want to verify, such…
Playwright is another popular end to end testing tool, notable for supporting multiple browsers, including Chrome, Firefox, and Safari, from a single test suite, and for generally…
Both Cypress and Playwright let you intercept outgoing network requests and respond with fake data instead of letting the request actually reach a real server, making tests faster,…
- Why should a team combine end to end tests with unit tests rather than relying on just one type? Beginner
Unit tests are fast and pinpoint exactly which small piece of code broke, but cannot catch problems that only appear when pieces are combined together, like a broken navigation flo…
Forms
All 5 questionsTemplate driven forms build the form structure mostly in the HTML template, using ngModel for two way binding and letting Angular create the form control objects behind the scenes…
- How do you add validation to a reactive form field, and how do you show an error message to the user? Intermediate
You pass one or more validator functions, like Validators.required, when creating a FormControl, and check the control's valid and touched properties in your template to decide whe…
You use a FormArray, which holds a dynamic list of form controls, letting you add or remove entries at runtime, such as letting a user add as many phone numbers as they need, while…
An asynchronous validator function returns an observable or a promise instead of a plain value, letting you perform something like an API call to check availability, with Angular a…
You bind to the form's ngSubmit event instead of the native submit event, and Angular automatically prevents the default page reload behavior for you, letting your component's own…
HTTP Client & Interceptors
All 5 questionsYou inject the HttpClient service into your component or service, and call its get method with the target URL, which returns an observable that emits the response once the request…
An interceptor lets you intercept every outgoing HTTP request and incoming response, allowing you to modify them consistently in one central place, such as automatically adding an…
- How would you handle errors from an HTTP request in Angular, showing a friendly message to the user? Intermediate
You use the catchError operator inside the observable's pipe, letting you catch any error the request throws, log it if needed, and return a fallback value or rethrow a more user f…
You combine an interceptor with RxJS's retry operator, which automatically resubscribes to a failed request a specified number of times, useful for handling brief, temporary networ…
You call the post method on HttpClient, passing the target URL and the data you want to send as the request body, which Angular automatically converts to JSON by default, and it re…
Internationalization (i18n) in Angular
All 5 questions- What is internationalization in Angular, and what built in tool does the framework provide for it? Beginner
Internationalization, often shortened to i18n, means building an app so it can easily show text in different languages for different users around the world. Angular provides a buil…
Unlike Angular's built in i18n, which requires a separate build for each language, ngx-translate loads translation files at runtime and lets a user switch languages instantly witho…
Angular's i18n system provides an ICU expression syntax specifically for plurals, letting you define separate translations for different count ranges directly inside your template,…
- How do you format dates, numbers, and currency correctly for different locales in an Angular app? Intermediate
Angular provides built in pipes, like date, number, and currency, that automatically format values according to the active locale, showing dates, decimal separators, and currency s…
- How would you let a user switch the display language of an Angular app using a simple dropdown menu? Beginner
With a runtime translation approach like ngx-translate, you store the currently selected language and call the service's use method whenever the user picks a new option, letting al…
Lifecycle Hooks
All 5 questionsLifecycle hooks are special methods Angular calls automatically at specific points in a component's life, such as right after it is created or right before it is destroyed, letting…
- What does ngOnDestroy do, and why is it important for cleaning up resources like subscriptions? Intermediate
ngOnDestroy runs right before Angular removes a component from the page, giving you a chance to clean up anything that would otherwise keep running unnecessarily, such as unsubscri…
ngOnChanges runs whenever one of a component's input properties changes, including the very first time it receives a value, and it receives an object describing exactly what change…
- What is the correct order in which Angular calls the main lifecycle hooks during a component's life? Advanced
Angular calls them in a predictable sequence: ngOnChanges first if there are any inputs, then ngOnInit once, followed by ngDoCheck, ngAfterContentInit, ngAfterContentChecked, ngAft…
The constructor's main job is simply setting up dependency injection, and at that point Angular has not yet fully set up the component's inputs or view. Fetching data or performing…
Micro Frontends with Angular
All 5 questions- What is a micro frontend architecture, and why might a large organization choose it for their Angular apps? Intermediate
A micro frontend architecture splits a large web application into several smaller, independently developed and deployed applications, often owned by separate teams, that are then c…
Module Federation lets one application expose specific modules, and another completely separate application load and use those modules directly at runtime, without needing both to…
- What are the main strategies for composing multiple micro frontends together into one user experience? Intermediate
Common strategies include a shell application that dynamically loads other applications at runtime, often using Module Federation, using web components like Angular Elements to emb…
Common challenges include keeping a consistent design and user experience across independently built pieces, managing shared state between separate applications that do not natural…
- When is a micro frontend architecture usually not worth the added complexity for a project? Beginner
For smaller applications or teams, a micro frontend architecture adds significant operational complexity, like managing multiple deployments, shared dependency versions, and cross…
New Control Flow Syntax (@if, @for & @switch)
All 5 questionsThe at if block is a newer, built in template syntax for conditionally showing content, reading more like a regular programming language conditional than the older asterisk ngIf st…
- How does the new at for control flow block work, and why does it require a track expression? Beginner
The at for block repeats a piece of template content for every item in a list, similar to the older ngFor directive, but it requires a track expression, telling Angular exactly how…
- How does the new at switch control flow block let you handle multiple possible conditions cleanly? Intermediate
The at switch block lets you check a single value against several possible cases, rendering different content for each matching case, similar to a switch statement in regular progr…
Because the new syntax is built directly into Angular's template compiler rather than relying on separate directive classes, Angular can generate more efficient instructions during…
Angular provides a CLI schematic that automatically scans your templates and converts the older structural directive syntax to the new at if and at for blocks, handling the common…
NgModules & Modular Architecture
All 5 questionsAn NgModule is a class decorated with the NgModule decorator that groups together related components, directives, pipes, and services, declaring what belongs together and what that…
A feature module groups together everything related to one specific area of functionality, such as an orders feature or a user settings feature, keeping that area's components, ser…
- How do you lazy load a feature module so its code is only downloaded when a user actually navigates to it? Intermediate
You configure the router to load a module using loadChildren with a dynamic import statement, rather than directly importing and declaring the module upfront, telling Angular to on…
- Why has Angular moved toward standalone components as the recommended default over NgModules? Advanced
Standalone components remove a significant amount of boilerplate, since each component explicitly declares its own dependencies directly rather than needing to be registered inside…
A SharedModule traditionally grouped together commonly reused components, directives, and pipes that many different feature modules needed, avoiding the need to import each one ind…
NgRx State Management
All 5 questionsNgRx is a state management library for Angular, inspired by Redux, that keeps all of an app's shared state in one single central store. The only way to change that state is by disp…
- How do you select a specific piece of state from the NgRx store and use it in a component? Intermediate
You use a selector function, created with createSelector, to describe exactly which piece of state you want, then inject the Store service and call its select method with that sele…
An Effect listens for a specific action, performs an asynchronous operation like an HTTP request, and then dispatches a new action once that operation completes, keeping asynchrono…
- What is the NgRx Entity library, and how does it simplify managing collections of data, like a list of users? Intermediate
NgRx Entity provides a standard, normalized way to store collections of similar items, keyed by their unique id, along with prebuilt functions for common operations like adding, up…
For small to medium apps, a simple service combined with signals is often perfectly sufficient and much easier to learn. NgRx becomes valuable for very large apps with complex, fre…
Performance & Lazy Loading
All 5 questionsLazy loading means only downloading the code for a specific feature or route when the user actually navigates to it, instead of including everything in the app's initial bundle. Th…
- How does the OnPush change detection strategy improve performance in a large Angular application? Intermediate
OnPush tells Angular to only check a component when its inputs change by reference, an event happens inside it, or an observable it depends on emits, rather than checking it on eve…
The at defer block lets you delay loading and rendering a piece of a template until a specific trigger happens, such as the element becoming visible on screen, the user interacting…
Without a tracking expression, Angular assumes every item in a list might be a completely different one whenever the list reference changes, potentially destroying and recreating e…
- How do you check your Angular app's actual bundle size and find opportunities to reduce it? Beginner
You build your app for production and use a bundle analysis tool, like source-map-explorer, to visualize exactly which packages and files are taking up the most space, helping you…
Pipes (Built-in & Custom)
All 5 questionsA pipe transforms a value directly inside your template for display purposes, without needing to write that transformation logic inside your component class. You apply a pipe using…
Angular provides several useful built in pipes, including date for formatting dates, uppercase and lowercase for changing text casing, currency and number for formatting numeric va…
You create a class decorated with the Pipe decorator, specifying a name to use in templates, and implement a transform method that receives the input value and any arguments, retur…
A pure pipe, the default type, only recalculates its output when its actual input value changes by reference, making it very efficient. An impure pipe recalculates on every single…
- How does the async pipe simplify working with observables directly in an Angular template? Intermediate
The async pipe automatically subscribes to an observable or promise, displays its most recently emitted value, and automatically unsubscribes when the component is destroyed, savin…
Progressive Web Apps (PWA) with Angular
All 5 questions- What is a Progressive Web App, and how do you add PWA support to an existing Angular project? Beginner
A Progressive Web App is a website that behaves more like a native app, capable of working offline, being installed on a device's home screen, and loading quickly even on unreliabl…
- What is a service worker, and what role does it play in making an Angular app work offline? Intermediate
A service worker is a script that runs separately from your app in the background, intercepting network requests and deciding whether to serve a cached response or fetch a fresh on…
The manifest.webmanifest file describes metadata about your app, such as its name, icons, theme color, and how it should appear when installed on a device's home screen, letting br…
Angular's SwUpdate service lets you subscribe to version update events, detecting when the service worker has downloaded a new version of the app in the background, letting you sho…
- Why might a company choose to build a Progressive Web App instead of a separate native mobile app? Beginner
A Progressive Web App can be built and maintained as a single codebase, deployed instantly through a normal website deployment rather than through app store approval processes, and…
Router Guards & Resolvers
All 5 questionsA route guard is a function that runs before a route is activated, deciding whether navigation should be allowed to continue, redirected elsewhere, or blocked entirely. A very comm…
- What is the canDeactivate guard used for, and how would you use it to warn a user about unsaved changes? Intermediate
The canDeactivate guard runs before a user navigates away from a route, letting you check whether it is actually safe to leave, such as prompting the user to confirm if they have u…
A resolver fetches data before a route actually activates, ensuring the component already has the data it needs the moment it appears on screen, rather than showing an empty or loa…
You list several guard functions in the canActivate array for a route, and Angular runs them in order, only allowing navigation to proceed if every single guard returns true, letti…
Fetching data inside ngOnInit means the component renders first, often showing a brief loading state, before the data actually arrives. A resolver instead delays the route's naviga…
Routing
All 5 questionsClient side routing lets a user navigate between different pages, called views, of a single page app without the browser actually reloading the page from the server every single ti…
Instead of a regular HTML anchor tag, which would cause a full page reload, Angular provides the routerLink directive that changes the current page smoothly using client side routi…
- How do you read a dynamic value from the URL, such as a product id, in an Angular route? Intermediate
You define a route with a colon before a parameter name, like colon id, and inject the ActivatedRoute service to access that specific value from the current web address inside your…
You nest a children array inside a parent route definition, and place a router outlet inside the parent component's template, letting the parent's own layout, like a shared sidebar…
You inject the Router service and call its navigate method with the path you want to go to, useful right after a successful form submission or login, without relying on the user cl…
RxJS & Observables
All 5 questionsAn observable represents a stream of values that can arrive over time, and you subscribe to it to receive those values as they happen. Unlike a promise, which resolves with exactly…
map transforms each emitted value into something else, similar to the array method of the same name. filter only lets through values matching a specific condition. switchMap is use…
- What is the difference between a Subject, a BehaviorSubject, and a ReplaySubject in RxJS? Intermediate
A plain Subject only emits values to subscribers that are already subscribed at the moment a value is sent, missing anything emitted before they subscribed. A BehaviorSubject alway…
The combineLatest operator lets you combine the most recent values from several observables into a single observable, emitting a new combined value whenever any one of the source o…
- Why is it important to unsubscribe from an RxJS observable, and what are common ways to do this correctly in Angular? Intermediate
Forgetting to unsubscribe from a long lived observable, such as one tied to a manually created subscription, can cause a memory leak, since the subscription and anything it referen…
Server-Side Rendering with Angular Universal
All 5 questions- What is server side rendering in Angular, and why would a team enable it using Angular Universal? Beginner
Server side rendering means generating the full HTML for a page on the server before sending it to the browser, instead of sending an almost empty page and building everything with…
- What is hydration in the context of Angular server side rendering, and why is it necessary? Intermediate
Hydration is the process where Angular takes the already rendered HTML sent from the server and attaches the necessary behavior to it in the browser, making buttons clickable and i…
You use Angular's TransferState feature together with your normal data fetching services, letting data fetched during server rendering be passed along to the browser, so the client…
APIs that only exist in a browser, like window, document, or localStorage, are not available in the Node.js environment used for server rendering, and accessing them directly will…
Server side rendering improves how quickly visitors see meaningful content, since the browser receives already built HTML instead of an empty shell. It also improves how well searc…
Services & Dependency Injection
All 5 questionsA service is a class dedicated to a specific piece of functionality, such as fetching data from a server or managing shared application state, kept separate from components so that…
Dependency injection means a component or another service does not create its own dependencies directly, but instead receives them automatically, usually through its constructor, f…
- How does the newer inject function differ from using constructor based dependency injection in Angular? Intermediate
The inject function lets you request a dependency directly inside a property initializer or a function, rather than only inside a constructor, which can make code more concise, esp…
Angular's injector system is hierarchical, meaning a service provided inside a specific component's providers array creates a new, separate instance just for that component and its…
- How would you mock a service during testing to isolate a component from its real dependencies? Intermediate
You provide a fake, simplified version of the service in your test's configuration, replacing the real one, letting you control exactly what data or behavior the component receives…
Standalone Components
All 5 questionsA standalone component declares its own dependencies, like which other components or directives it uses, directly within itself using an imports array, without needing to be regist…
You call bootstrapApplication with your root standalone component, and provide any application wide services or configuration directly as providers, completely skipping the traditi…
- How do standalone components handle lazy loading differently from NgModule based lazy loading? Intermediate
Instead of lazy loading an entire feature module, you can lazy load a single standalone component directly in your route configuration using loadComponent, letting you split your a…
- How would you migrate an existing NgModule based Angular application to standalone components? Advanced
Angular provides an official CLI schematic that automatically analyzes your existing NgModules and converts your components, directives, and pipes to standalone versions, updating…
- Why does the standalone components approach generally result in smaller final bundle sizes? Beginner
Because each standalone component explicitly lists exactly what it depends on, Angular's build tools can more easily determine which code is actually used and safely remove anythin…
State Management
All 5 questionsState management refers to how an app organizes and shares data that changes over time, such as the current logged in user, items in a shopping cart, or a form's values. Small apps…
- How do signals simplify state management compared to relying entirely on RxJS observables? Intermediate
Signals let you read and update a value directly and synchronously, without needing to subscribe or manage a subscription's lifecycle, making many common state management scenarios…
A simple signal based service works well for most small to medium apps, especially with straightforward shared state. NgRx becomes valuable for very large apps with complex, freque…
- What does it mean for state to be normalized, and why does this matter for larger Angular apps? Intermediate
Normalized state stores related data, like users and their posts, as separate flat collections referenced by id, instead of deeply nesting one inside the other. This avoids duplica…
- What is a common sign that an Angular app's state management approach needs to be reconsidered? Beginner
If the same piece of data needs to be passed through many layers of components that do not actually use it themselves, often called prop drilling, or if unrelated parts of an app f…
Template Reference Variables & ViewChild
All 5 questionsA template reference variable, created with a hash symbol directly in your template, gives you a way to refer to a DOM element or a component instance from elsewhere within that sa…
ViewChild lets a parent component get a direct reference to a child component or a DOM element within its own template, from inside the parent's TypeScript class, letting the paren…
- How does the newer signal based viewChild function differ from the traditional ViewChild decorator? Intermediate
The viewChild function returns a signal instead of a plain property, letting you read the referenced element or component reactively, and it can be marked as required, causing a cl…
ViewChildren returns a QueryList containing every matching element or component instance found in the parent's template, which you can iterate over like an array, and it automatica…
ViewChild accesses an element or component that is part of a component's own template, defined directly by that component. ContentChild accesses an element or component that was pr…
Testing with Jasmine & Karma
All 5 questionsJasmine is a testing framework that provides the actual syntax for writing tests, like describe and it blocks and expect assertions. Karma is a test runner that executes those test…
TestBed lets you configure a testing module specifically for your test, providing either the real service or a mock version, then create an instance of your component within that c…
- How would you test that clicking a button in a component triggers the expected behavior? Intermediate
You find the button element in the rendered component's DOM, simulate a click event on it using dispatchEvent, run change detection to let Angular process the resulting update, and…
You use Angular's HttpClientTestingModule and the HttpTestingController, which let you intercept outgoing requests during a test, verify the exact request was made correctly, and m…
A unit test checks a small, isolated piece of logic, like a single function or service method, completely on its own, often without needing Angular's TestBed at all. A component te…
TypeScript with Angular
All 5 questions- Why does Angular use TypeScript instead of plain JavaScript, and what benefit does it provide? Beginner
TypeScript adds type checking to JavaScript, catching many common mistakes, like passing the wrong kind of value to a component, before the code even runs, right inside your code e…
TypeScript usually figures out the correct type automatically based on the initial value you give the signal function, but you can also specify the type explicitly inside angle bra…
You define an interface describing the exact shape of the expected data, and use it as the generic type parameter when calling HttpClient methods, letting TypeScript check that you…
TypeScript generics let a component's input types adapt to whatever specific data type is actually passed in, letting you write one flexible list component that works correctly and…
Strict mode enables a stricter set of TypeScript checks, such as disallowing implicit any types and requiring null checks before using a potentially null value, catching more poten…
Zoneless Change Detection & Zone.js
All 5 questionsZone.js is a library that Angular has historically relied on to automatically detect when something in your application might have changed, such as after a click event, a timer, or…
- What does zoneless change detection mean, and how does Angular know when to update the screen without Zone.js? Intermediate
Zoneless change detection removes Zone.js entirely and instead relies on more explicit and precise signals, like Angular Signals, to tell Angular exactly which parts of the applica…
Removing Zone.js reduces the amount of JavaScript the browser needs to download and parse, avoids the overhead of patching many browser APIs, and generally leads to faster startup…
You gradually convert components to use signals instead of plain class properties for reactive state, replace manual change detection triggers where needed, verify that any third p…
- Why is Angular investing in zoneless change detection as the future direction for the framework? Beginner
Zoneless change detection makes Angular apps faster and lighter by removing the need to patch and monitor every possible browser event, while also making it easier to debug because…