Angular Interview Master
Accelerate your career with 200+ Professional Questions from Beginner to Architect level.
What is Angular?
BeginnerAngular is a platform and framework for building single-page client applications using HTML and TypeScript. It is developed and maintained by Google a...
Expert Explanation:
Angular is a platform and framework for building single-page client applications using HTML and TypeScript. It is developed and maintained by Google and provides a set of tools for building scalable and high-performance web applications.
What are the key features of Angular?
BeginnerKey features include Component-based architecture, Two-way data binding, Dependency Injection, Templates, Directives, Pipes, Routing, and RxJS integra...
Expert Explanation:
Key features include Component-based architecture, Two-way data binding, Dependency Injection, Templates, Directives, Pipes, Routing, and RxJS integration.
What is TypeScript?
BeginnerTypeScript is a superset of JavaScript that adds static typing. Angular is built with TypeScript, which provides better tooling, refactoring capabilit...
Expert Explanation:
TypeScript is a superset of JavaScript that adds static typing. Angular is built with TypeScript, which provides better tooling, refactoring capabilities, and helps catch errors at compile-time.
What is a Component in Angular?
BeginnerA component is the fundamental building block of an Angular application. It consists of a TypeScript class (logic), an HTML template (view), and CSS s...
Expert Explanation:
A component is the fundamental building block of an Angular application. It consists of a TypeScript class (logic), an HTML template (view), and CSS styles.
What is a Template?
BeginnerA template is a form of HTML that tells Angular how to render the component's view. It uses special syntax like {{ }} for interpolation and [ ] for pr...
Expert Explanation:
A template is a form of HTML that tells Angular how to render the component's view. It uses special syntax like {{ }} for interpolation and [ ] for property binding.
What is Data Binding?
BeginnerData binding is a mechanism that allows communication between the component's class and its template. Types include Interpolation, Property Binding, E...
Expert Explanation:
Data binding is a mechanism that allows communication between the component's class and its template. Types include Interpolation, Property Binding, Event Binding, and Two-way Data Binding.
Difference between Angular and AngularJS?
BeginnerAngularJS is the 1.x version based on JavaScript. Angular (2+) is a complete rewrite based on TypeScript, featuring a component-based architecture, be...
Expert Explanation:
AngularJS is the 1.x version based on JavaScript. Angular (2+) is a complete rewrite based on TypeScript, featuring a component-based architecture, better performance, and mobile support.
What are Directives?
BeginnerDirectives are markers on a DOM element that tell Angular to attach behavior to it. There are three types: Component Directives, Structural Directives...
Expert Explanation:
Directives are markers on a DOM element that tell Angular to attach behavior to it. There are three types: Component Directives, Structural Directives (*ngIf, *ngFor), and Attribute Directives (ngClass, ngStyle).
What is an Angular Module (@NgModule)?
BeginnerAn NgModule is a decorator that describes how the application parts fit together. It declares components, directives, and pipes, and imports other mod...
Expert Explanation:
An NgModule is a decorator that describes how the application parts fit together. It declares components, directives, and pipes, and imports other modules.
What is Dependency Injection?
BeginnerDependency Injection (DI) is a design pattern where a class requests dependencies from external sources rather than creating them. Angular's DI system...
Expert Explanation:
Dependency Injection (DI) is a design pattern where a class requests dependencies from external sources rather than creating them. Angular's DI system provides instances of services to components.
What are Pipes in Angular?
BeginnerPipes are simple functions used in templates to transform data for display. Examples include DatePipe, UpperCasePipe, and CurrencyPipe.
Expert Explanation:
Pipes are simple functions used in templates to transform data for display. Examples include DatePipe, UpperCasePipe, and CurrencyPipe.
What is the purpose of the 'async' pipe?
BeginnerThe async pipe automatically subscribes to an Observable or Promise and returns the latest value it has emitted. It also automatically unsubscribes wh...
Expert Explanation:
The async pipe automatically subscribes to an Observable or Promise and returns the latest value it has emitted. It also automatically unsubscribes when the component is destroyed.
What is Interpolation?
BeginnerInterpolation allows you to embed expressions into HTML templates using double curly braces {{ expression }}. Angular evaluates the expression and con...
Expert Explanation:
Interpolation allows you to embed expressions into HTML templates using double curly braces {{ expression }}. Angular evaluates the expression and converts the result to text.
What is Property Binding?
BeginnerProperty binding [property]="value" allows you to set properties of HTML elements or directives. It is a one-way data binding from component to view.
Expert Explanation:
Property binding [property]="value" allows you to set properties of HTML elements or directives. It is a one-way data binding from component to view.
What is Event Binding?
BeginnerEvent binding (event)="handler()" allows you to listen for and respond to user actions such as keystrokes, mouse movements, clicks, and touches.
Expert Explanation:
Event binding (event)="handler()" allows you to listen for and respond to user actions such as keystrokes, mouse movements, clicks, and touches.
What is Two-way Data Binding?
BeginnerTwo-way data binding [(ngModel)]="property" combines property and event binding. Changes in the component update the view, and changes in the view upd...
Expert Explanation:
Two-way data binding [(ngModel)]="property" combines property and event binding. Changes in the component update the view, and changes in the view update the component.
What is a Service in Angular?
BeginnerA service is a class with a specific purpose (e.g., fetching data, logging). It is typically decorated with @Injectable() and shared across components...
Expert Explanation:
A service is a class with a specific purpose (e.g., fetching data, logging). It is typically decorated with @Injectable() and shared across components via DI.
What is the @Injectable() decorator?
BeginnerIt marks a class as available to be provided and injected as a dependency. The 'providedIn: root' property makes it a singleton across the app.
Expert Explanation:
It marks a class as available to be provided and injected as a dependency. The 'providedIn: root' property makes it a singleton across the app.
Explain Angular Life Cycle Hooks.
BeginnerAngular provides hooks like ngOnInit, ngOnChanges, ngAfterViewInit, and ngOnDestroy to tap into key events in a component's lifecycle.
Expert Explanation:
Angular provides hooks like ngOnInit, ngOnChanges, ngAfterViewInit, and ngOnDestroy to tap into key events in a component's lifecycle.
What is ngOnInit()?
BeginnerngOnInit is a lifecycle hook called after Angular has initialized all data-bound properties. It is the best place for initialization logic (e.g., API ...
Expert Explanation:
ngOnInit is a lifecycle hook called after Angular has initialized all data-bound properties. It is the best place for initialization logic (e.g., API calls).
What is ngOnDestroy()?
BeginnerngOnDestroy is a hook called just before Angular destroys the component. It is used for cleanup, such as unsubscribing from Observables and detaching ...
Expert Explanation:
ngOnDestroy is a hook called just before Angular destroys the component. It is used for cleanup, such as unsubscribing from Observables and detaching event handlers.
What is the Angular CLI?
BeginnerThe Angular Command Line Interface (CLI) is a tool used to initialize, develop, scaffold, and maintain Angular applications directly from a command sh...
Expert Explanation:
The Angular Command Line Interface (CLI) is a tool used to initialize, develop, scaffold, and maintain Angular applications directly from a command shell.
How do you create a component using CLI?
BeginnerUse the command: ng generate component component-name (or ng g c component-name).
Expert Explanation:
Use the command: ng generate component component-name (or ng g c component-name).
What is a Single Page Application (SPA)?
BeginnerAn SPA is a web application that interacts with the user by dynamically rewriting the current page rather than loading entire new pages from a server.
Expert Explanation:
An SPA is a web application that interacts with the user by dynamically rewriting the current page rather than loading entire new pages from a server.
What is the purpose of main.ts?
Beginnermain.ts is the entry point of the Angular application. It bootstraps the root module (usually AppModule) to start the app.
Expert Explanation:
main.ts is the entry point of the Angular application. It bootstraps the root module (usually AppModule) to start the app.
What is the purpose of polyfills.ts?
BeginnerPolyfills are scripts that provide modern functionality on older browsers that do not natively support it.
Expert Explanation:
Polyfills are scripts that provide modern functionality on older browsers that do not natively support it.
What is a Selector?
BeginnerA selector is a CSS selector that tells Angular where to instantiate a component in the HTML template. Example: selector: 'app-root'.
Expert Explanation:
A selector is a CSS selector that tells Angular where to instantiate a component in the HTML template. Example: selector: 'app-root'.
What is bootstrapping in Angular?
BeginnerBootstrapping is the process of initializing and launching the Angular application by loading the root module and root component.
Expert Explanation:
Bootstrapping is the process of initializing and launching the Angular application by loading the root module and root component.
What is @Input() decorator?
Beginner@Input() allows a parent component to pass data to a child component.
Expert Explanation:
@Input() allows a parent component to pass data to a child component.
What is @Output() decorator?
Beginner@Output() allows a child component to emit events to its parent component, typically using an EventEmitter.
Expert Explanation:
@Output() allows a child component to emit events to its parent component, typically using an EventEmitter.
What is EventEmitter?
BeginnerEventEmitter is a class used in Angular components to emit custom events that a parent component can listen to via event binding.
Expert Explanation:
EventEmitter is a class used in Angular components to emit custom events that a parent component can listen to via event binding.
What are Structural Directives?
BeginnerStructural directives change the DOM layout by adding or removing elements. Common examples are *ngIf (conditional) and *ngFor (looping).
Expert Explanation:
Structural directives change the DOM layout by adding or removing elements. Common examples are *ngIf (conditional) and *ngFor (looping).
What are Attribute Directives?
BeginnerAttribute directives change the appearance or behavior of an existing element. Examples include ngClass and ngStyle.
Expert Explanation:
Attribute directives change the appearance or behavior of an existing element. Examples include ngClass and ngStyle.
Difference between *ngIf and hidden property?
Beginner*ngIf removes/adds the element from the DOM entirely, while the 'hidden' property merely hides it via CSS (display: none), keeping it in the DOM.
Expert Explanation:
*ngIf removes/adds the element from the DOM entirely, while the 'hidden' property merely hides it via CSS (display: none), keeping it in the DOM.
What is the purpose of index.html?
Beginnerindex.html is the main HTML file that is served when someone visits your site. It contains the root component selector where the app is injected.
Expert Explanation:
index.html is the main HTML file that is served when someone visits your site. It contains the root component selector where the app is injected.
What is package.json?
Beginnerpackage.json lists the dependencies and scripts required for the project. It is used by npm or yarn to manage library versions.
Expert Explanation:
package.json lists the dependencies and scripts required for the project. It is used by npm or yarn to manage library versions.
What is angular.json?
Beginnerangular.json is the configuration file for the Angular CLI. It defines build, test, and serve settings for the workspace.
Expert Explanation:
angular.json is the configuration file for the Angular CLI. It defines build, test, and serve settings for the workspace.
What is a constructor?
BeginnerThe constructor is a standard TypeScript class method called when the class is instantiated. In Angular, it is primarily used for Dependency Injection...
Expert Explanation:
The constructor is a standard TypeScript class method called when the class is instantiated. In Angular, it is primarily used for Dependency Injection.
Difference between constructor and ngOnInit?
BeginnerThe constructor is for DI; ngOnInit is for Angular-specific initialization. Inputs are not available in the constructor but are available in ngOnInit.
Expert Explanation:
The constructor is for DI; ngOnInit is for Angular-specific initialization. Inputs are not available in the constructor but are available in ngOnInit.
How to perform an HTTP request in Angular?
BeginnerUse the HttpClient service provided in HttpClientModule. It returns Observables for handling asynchronous data.
Expert Explanation:
Use the HttpClient service provided in HttpClientModule. It returns Observables for handling asynchronous data.
What is an Observable?
BeginnerAn Observable is a stream of data that can be observed over time. It is part of the RxJS library and is used extensively in Angular for handling async...
Expert Explanation:
An Observable is a stream of data that can be observed over time. It is part of the RxJS library and is used extensively in Angular for handling async operations.
What is the subscribe() method?
BeginnerThe subscribe() method is used to listen to an Observable. The callback function provided to subscribe is executed whenever the Observable emits a new...
Expert Explanation:
The subscribe() method is used to listen to an Observable. The callback function provided to subscribe is executed whenever the Observable emits a new value.
How to handle errors in HTTP requests?
BeginnerErrors can be handled using the catchError operator from RxJS or by providing an error callback to the subscribe() method.
Expert Explanation:
Errors can be handled using the catchError operator from RxJS or by providing an error callback to the subscribe() method.
What is a Promise?
BeginnerA Promise is a JavaScript object representing the eventual completion (or failure) of an asynchronous operation and its resulting value.
Expert Explanation:
A Promise is a JavaScript object representing the eventual completion (or failure) of an asynchronous operation and its resulting value.
Observable vs Promise?
BeginnerObservables are lazy, cancellable, and handle multiple values. Promises are eager, not cancellable, and handle only a single value.
Expert Explanation:
Observables are lazy, cancellable, and handle multiple values. Promises are eager, not cancellable, and handle only a single value.
What is Routing in Angular?
BeginnerRouting allows navigating between different views or components based on the URL in the browser's address bar.
Expert Explanation:
Routing allows navigating between different views or components based on the URL in the browser's address bar.
What is router-outlet?
BeginnerThe <router-outlet> is a directive that acts as a placeholder where Angular dynamically inserts the component matched by the current route.
Expert Explanation:
The <router-outlet> is a directive that acts as a placeholder where Angular dynamically inserts the component matched by the current route.
What is routerLink?
BeginnerrouterLink is a directive used to link to different routes in an Angular application. It is preferred over 'href' because it prevents a full page relo...
Expert Explanation:
routerLink is a directive used to link to different routes in an Angular application. It is preferred over 'href' because it prevents a full page reload.
What is an Interceptor?
BeginnerAn HTTP Interceptor is a service that can inspect or transform HTTP requests and responses globally before they reach the server or the app.
Expert Explanation:
An HTTP Interceptor is a service that can inspect or transform HTTP requests and responses globally before they reach the server or the app.
What is ViewEncapsulation?
BeginnerViewEncapsulation determines whether the styles defined in a component will affect the whole application or just that specific component. Options incl...
Expert Explanation:
ViewEncapsulation determines whether the styles defined in a component will affect the whole application or just that specific component. Options include Emulated, None, and ShadowDom.
Difference between Reactive Forms and Template-driven Forms?
ExperienceTemplate-driven forms are easy to use but harder to test and scale (using ngModel). Reactive forms are more robust, scalable, and testable, offering s...
Expert Explanation:
Template-driven forms are easy to use but harder to test and scale (using ngModel). Reactive forms are more robust, scalable, and testable, offering synchronous access to data models.
What is the purpose of FormBuilder?
ExperienceFormBuilder is a syntactic sugar service that provides convenient methods for generating instances of FormControl, FormGroup, and FormArray.
Expert Explanation:
FormBuilder is a syntactic sugar service that provides convenient methods for generating instances of FormControl, FormGroup, and FormArray.
What is FormArray?
ExperienceFormArray is a class that tracks the value and validity state of an array of FormControl, FormGroup, or FormArray instances. It is useful for dynamic ...
Expert Explanation:
FormArray is a class that tracks the value and validity state of an array of FormControl, FormGroup, or FormArray instances. It is useful for dynamic lists of form fields.
Explain Angular Dependency Injection hierarchy.
ExperienceAngular DI is hierarchical. If a dependency isn't found in the component's injector, it looks up to parent components, then to the module/root level. ...
Expert Explanation:
Angular DI is hierarchical. If a dependency isn't found in the component's injector, it looks up to parent components, then to the module/root level. 'providedIn: root' creates a singleton.
What are Route Guards?
ExperienceGuards are interfaces that can permit or deny navigation to a route. Common guards include CanActivate, CanDeactivate, Resolve, and CanMatch (modern r...
Expert Explanation:
Guards are interfaces that can permit or deny navigation to a route. Common guards include CanActivate, CanDeactivate, Resolve, and CanMatch (modern replacement for CanLoad).
What is Lazy Loading?
ExperienceLazy loading is a technique that loads NgModules only when they are needed (e.g., when a user navigates to a specific route), reducing initial bundle ...
Expert Explanation:
Lazy loading is a technique that loads NgModules only when they are needed (e.g., when a user navigates to a specific route), reducing initial bundle size and improving load time.
How to implement Lazy Loading?
ExperienceUse the 'loadChildren' property in route configuration with an arrow function: loadChildren: () => import('./module-path').then(m => m.ModuleName).
Expert Explanation:
Use the 'loadChildren' property in route configuration with an arrow function: loadChildren: () => import('./module-path').then(m => m.ModuleName).
What is the purpose of Resolve guard?
ExperienceThe Resolve guard is used to fetch data before navigating to a route, ensuring the component has all necessary data ready when it's initialized.
Expert Explanation:
The Resolve guard is used to fetch data before navigating to a route, ensuring the component has all necessary data ready when it's initialized.
What is NgZone and why is it used?
ExperienceNgZone is a wrapper around Zone.js that helps Angular detect asynchronous changes and trigger change detection. 'runOutsideAngular' can improve perfor...
Expert Explanation:
NgZone is a wrapper around Zone.js that helps Angular detect asynchronous changes and trigger change detection. 'runOutsideAngular' can improve performance for high-frequency events.
Explain Change Detection strategies.
ExperienceAngular has two strategies: Default (checks everything on every event) and OnPush (only checks when Inputs change or an event occurs within the compon...
Expert Explanation:
Angular has two strategies: Default (checks everything on every event) and OnPush (only checks when Inputs change or an event occurs within the component).
How does OnPush strategy work?
ExperienceWith OnPush, Angular only runs change detection if an @Input property reference changes, an event originated in the component, or change detection is ...
Expert Explanation:
With OnPush, Angular only runs change detection if an @Input property reference changes, an event originated in the component, or change detection is manually triggered.
What is the purpose of ChangeDetectorRef?
ExperienceIt is a service used to manually trigger change detection (detectChanges), detach from the change detection tree (detach), or mark for check (markForC...
Expert Explanation:
It is a service used to manually trigger change detection (detectChanges), detach from the change detection tree (detach), or mark for check (markForCheck).
What is Subject in RxJS?
ExperienceA Subject is both an Observable and an Observer. It allows values to be multicasted to many Observers. It acts as a bridge between non-reactive code a...
Expert Explanation:
A Subject is both an Observable and an Observer. It allows values to be multicasted to many Observers. It acts as a bridge between non-reactive code and Observers.
Difference between Subject and BehaviorSubject?
ExperienceA Subject doesn't have an initial value and only emits future values. A BehaviorSubject requires an initial value and emits the current value to new s...
Expert Explanation:
A Subject doesn't have an initial value and only emits future values. A BehaviorSubject requires an initial value and emits the current value to new subscribers immediately.
What is ReplaySubject?
ExperienceA ReplaySubject 'replays' a specified number of previous values to new subscribers, even if they subscribe long after the values were emitted.
Expert Explanation:
A ReplaySubject 'replays' a specified number of previous values to new subscribers, even if they subscribe long after the values were emitted.
Explain Content Projection.
ExperienceContent projection (using <ng-content>) allows a component to insert external content into its template. It helps create reusable wrapper components (...
Expert Explanation:
Content projection (using <ng-content>) allows a component to insert external content into its template. It helps create reusable wrapper components (e.g., cards, modals).
What is @ViewChild and @ViewChildren?
Experience@ViewChild is a decorator used to gain access to a child component, directive, or DOM element within its own template. @ViewChildren is for multiple r...
Expert Explanation:
@ViewChild is a decorator used to gain access to a child component, directive, or DOM element within its own template. @ViewChildren is for multiple results.
What is @ContentChild and @ContentChildren?
ExperienceSimilar to ViewChild, but used to access projected content (content inside <ng-content>) from the parent's template.
Expert Explanation:
Similar to ViewChild, but used to access projected content (content inside <ng-content>) from the parent's template.
What is an Angular Library?
ExperienceA library is an Angular project that cannot run on its own. It is compiled into a package that can be shared across multiple Angular applications.
Expert Explanation:
A library is an Angular project that cannot run on its own. It is compiled into a package that can be shared across multiple Angular applications.
How to share data between components?
ExperienceParent-to-child (@Input), Child-to-parent (@Output), Sibling components (shared service with Subject/Signals), or using a State Management library (Ng...
Expert Explanation:
Parent-to-child (@Input), Child-to-parent (@Output), Sibling components (shared service with Subject/Signals), or using a State Management library (NgRx).
What are Dynamic Components?
ExperienceComponents that are instantiated at runtime rather than being declared in a template. Use ViewContainerRef and ComponentFactoryResolver (deprecated) o...
Expert Explanation:
Components that are instantiated at runtime rather than being declared in a template. Use ViewContainerRef and ComponentFactoryResolver (deprecated) or modern 'createComponent'.
What is the purpose of 'trackBy' in *ngFor?
ExperiencetrackBy is a function that returns a unique identifier for items in a list. It helps Angular optimize performance by only re-rendering items that have...
Expert Explanation:
trackBy is a function that returns a unique identifier for items in a list. It helps Angular optimize performance by only re-rendering items that have changed.
How to optimize Angular app bundle size?
ExperienceUse Lazy Loading, AOT compilation, tree-shaking, production builds (ng build --prod), and analyze bundles using webpack-bundle-analyzer.
Expert Explanation:
Use Lazy Loading, AOT compilation, tree-shaking, production builds (ng build --prod), and analyze bundles using webpack-bundle-analyzer.
What is AOT vs JIT compilation?
ExperienceJIT (Just-in-Time) compiles code in the browser. AOT (Ahead-of-Time) compiles code during the build process, resulting in faster rendering and smaller...
Expert Explanation:
JIT (Just-in-Time) compiles code in the browser. AOT (Ahead-of-Time) compiles code during the build process, resulting in faster rendering and smaller browser payloads.
What is tree-shaking?
ExperienceTree-shaking is a build-time optimization that removes unused code from the final bundle, ensuring only the necessary parts of dependencies are includ...
Expert Explanation:
Tree-shaking is a build-time optimization that removes unused code from the final bundle, ensuring only the necessary parts of dependencies are included.
Explain Angular Signals (New in v16).
ExperienceSignals are a new reactive primitive that allows Angular to track change dependencies more granularly than Zone.js, leading to better performance and ...
Expert Explanation:
Signals are a new reactive primitive that allows Angular to track change dependencies more granularly than Zone.js, leading to better performance and simpler reactivity.
WritableSignal vs ComputedSignal?
ExperienceWritableSignals (signal()) allow updating values via set() or update(). ComputedSignals (computed()) are read-only and derive values from other signal...
Expert Explanation:
WritableSignals (signal()) allow updating values via set() or update(). ComputedSignals (computed()) are read-only and derive values from other signals.
What is effect() in Signals?
Experienceeffect() is a function that runs whenever the signal values it depends on change. It is typically used for side effects like logging or DOM manipulati...
Expert Explanation:
effect() is a function that runs whenever the signal values it depends on change. It is typically used for side effects like logging or DOM manipulation.
What are Standalone Components (v14+)?
ExperienceStandalone components allow creating components, directives, and pipes without an @NgModule. They simplify application structure and enable easier laz...
Expert Explanation:
Standalone components allow creating components, directives, and pipes without an @NgModule. They simplify application structure and enable easier lazy loading.
How to bootstrap a Standalone Application?
ExperienceUse the 'bootstrapApplication' function in main.ts, passing the root standalone component directly instead of a module.
Expert Explanation:
Use the 'bootstrapApplication' function in main.ts, passing the root standalone component directly instead of a module.
What is ProvideHttpClient (Standalone)?
ExperienceIn standalone apps, instead of HttpClientModule, you use 'provideHttpClient()' in the application config providers array.
Expert Explanation:
In standalone apps, instead of HttpClientModule, you use 'provideHttpClient()' in the application config providers array.
What is 'switchMap' vs 'mergeMap'?
ExperienceswitchMap cancels the previous inner observable and starts a new one. mergeMap handles all inner observables concurrently.
Expert Explanation:
switchMap cancels the previous inner observable and starts a new one. mergeMap handles all inner observables concurrently.
What is 'exhaustMap'?
ExperienceexhaustMap ignores new inner observables while a current one is still running. Useful for preventing duplicate submissions (e.g., login buttons).
Expert Explanation:
exhaustMap ignores new inner observables while a current one is still running. Useful for preventing duplicate submissions (e.g., login buttons).
What is 'concatMap'?
ExperienceconcatMap queues inner observables and runs them one by one in sequence, ensuring order is preserved.
Expert Explanation:
concatMap queues inner observables and runs them one by one in sequence, ensuring order is preserved.
Explain Custom Validators in Reactive Forms.
ExperienceA custom validator is a function that takes a FormControl and returns an error object (if invalid) or null (if valid).
Expert Explanation:
A custom validator is a function that takes a FormControl and returns an error object (if invalid) or null (if valid).
What is AsyncValidator?
ExperienceAn AsyncValidator returns a Promise or Observable that emits an error object or null. Used for server-side validation (e.g., checking if username exis...
Expert Explanation:
An AsyncValidator returns a Promise or Observable that emits an error object or null. Used for server-side validation (e.g., checking if username exists).
What is the purpose of 'HostListener'?
Experience@HostListener is a decorator that allows you to listen for events on the host element of a directive or component.
Expert Explanation:
@HostListener is a decorator that allows you to listen for events on the host element of a directive or component.
What is 'HostBinding'?
Experience@HostBinding allows you to set properties (like styles or classes) on the host element of a directive or component.
Expert Explanation:
@HostBinding allows you to set properties (like styles or classes) on the host element of a directive or component.
What is an Angular Workspace?
ExperienceAn Angular workspace is a directory containing one or more projects (apps or libraries) managed by the same CLI configuration.
Expert Explanation:
An Angular workspace is a directory containing one or more projects (apps or libraries) managed by the same CLI configuration.
How to use 'provide' in DI?
ExperienceThe 'provide' property allows you to map a token to a specific class (useClass), value (useValue), or factory function (useFactory).
Expert Explanation:
The 'provide' property allows you to map a token to a specific class (useClass), value (useValue), or factory function (useFactory).
What is InjectionToken?
ExperienceAn InjectionToken is used for DI when the dependency is not a class (e.g., a simple string, config object, or interface).
Expert Explanation:
An InjectionToken is used for DI when the dependency is not a class (e.g., a simple string, config object, or interface).
What is Multi-provider?
ExperienceSetting 'multi: true' in a provider allows multiple providers to be registered for the same token, resulting in an array of instances (common for inte...
Expert Explanation:
Setting 'multi: true' in a provider allows multiple providers to be registered for the same token, resulting in an array of instances (common for interceptors).
Explain 'Strict Template Checking'.
ExperienceA TypeScript compiler feature that ensures all types used in templates are correctly defined and checked against the component class.
Expert Explanation:
A TypeScript compiler feature that ensures all types used in templates are correctly defined and checked against the component class.
What is the 'Hydration' in Angular v16?
ExperienceFull client-side hydration allows Angular to reuse the existing DOM rendered by Server Side Rendering (SSR) without flickering or full re-rendering.
Expert Explanation:
Full client-side hydration allows Angular to reuse the existing DOM rendered by Server Side Rendering (SSR) without flickering or full re-rendering.
What is SSR (Angular Universal)?
ExperienceServer-Side Rendering (SSR) renders pages on the server and sends fully formed HTML to the browser, improving SEO and initial load speed.
Expert Explanation:
Server-Side Rendering (SSR) renders pages on the server and sends fully formed HTML to the browser, improving SEO and initial load speed.
How to handle memory leaks in Angular?
ExperienceMemory leaks usually occur from unclosed subscriptions. Fix by using the async pipe, 'takeUntil', or unsubscribing in ngOnDestroy.
Expert Explanation:
Memory leaks usually occur from unclosed subscriptions. Fix by using the async pipe, 'takeUntil', or unsubscribing in ngOnDestroy.
What is 'takeUntil' and why use it?
ExperiencetakeUntil is an RxJS operator used to automatically unsubscribe from an observable when a 'notifier' observable (usually a subject triggered in ngOnDe...
Expert Explanation:
takeUntil is an RxJS operator used to automatically unsubscribe from an observable when a 'notifier' observable (usually a subject triggered in ngOnDestroy) emits.
What is Angular DevTools?
ExperienceA browser extension for Chrome and Firefox that helps debug Angular apps by inspecting component hierarchies and change detection cycles.
Expert Explanation:
A browser extension for Chrome and Firefox that helps debug Angular apps by inspecting component hierarchies and change detection cycles.
Explain 'Schematics' in Angular CLI.
ExperienceSchematics are template-based code generators that are part of the Angular CLI. They are used for 'ng generate' and 'ng add'.
Expert Explanation:
Schematics are template-based code generators that are part of the Angular CLI. They are used for 'ng generate' and 'ng add'.
What is 'ng update'?
ExperienceThe 'ng update' command automatically updates your workspace and dependencies to the latest version, often running migration scripts automatically.
Expert Explanation:
The 'ng update' command automatically updates your workspace and dependencies to the latest version, often running migration scripts automatically.
Deep Dive: How does Zone.js work?
AdvancedZone.js 'monkey-patches' asynchronous APIs (setTimeout, addEventListener, Promise) to intercept their execution and notify Angular to run change detec...
Expert Explanation:
Zone.js 'monkey-patches' asynchronous APIs (setTimeout, addEventListener, Promise) to intercept their execution and notify Angular to run change detection.
Angular Architecture: Modular vs Standalone.
AdvancedModular uses @NgModule as a container; Standalone eliminates the module, making components the unit of organization. Standalone simplifies tree-shakin...
Expert Explanation:
Modular uses @NgModule as a container; Standalone eliminates the module, making components the unit of organization. Standalone simplifies tree-shaking and component-based routing.
State Management: Why NgRx?
AdvancedNgRx provides Redux-inspired reactive state management. It solves complexity in large apps by using a single source of truth, immutable state, and cle...
Expert Explanation:
NgRx provides Redux-inspired reactive state management. It solves complexity in large apps by using a single source of truth, immutable state, and clear patterns for side effects.
Explain 'Signals' vs 'RxJS' for Reactivity.
AdvancedSignals are optimized for UI-state synchronization (synchronous and glitch-free). RxJS is optimized for complex event streams and asynchronous operati...
Expert Explanation:
Signals are optimized for UI-state synchronization (synchronous and glitch-free). RxJS is optimized for complex event streams and asynchronous operations (time-based).
What is 'Micro Frontends' in Angular?
AdvancedAn architectural style where a large app is split into small independent apps that are integrated at runtime, often using Module Federation (Webpack).
Expert Explanation:
An architectural style where a large app is split into small independent apps that are integrated at runtime, often using Module Federation (Webpack).
Module Federation: How to implement?
AdvancedBy using the @angular-architects/module-federation plugin, which configures Webpack to share modules and load remote entries dynamically.
Expert Explanation:
By using the @angular-architects/module-federation plugin, which configures Webpack to share modules and load remote entries dynamically.
How to implement Custom Pipes with DI?
AdvancedPipes can inject services like any other class. Use @Injectable if you need to provide the pipe as a service, or just inject dependencies in the const...
Expert Explanation:
Pipes can inject services like any other class. Use @Injectable if you need to provide the pipe as a service, or just inject dependencies in the constructor.
Performance: Preloading Strategies.
AdvancedAngular offers PreloadAllModules or custom strategies (e.g., Quicklink) to load lazy modules in the background after the initial page load.
Expert Explanation:
Angular offers PreloadAllModules or custom strategies (e.g., Quicklink) to load lazy modules in the background after the initial page load.
Explain 'Deferred Loading' (@defer)?
AdvancedA v17 feature that allows declaratively loading parts of a template based on triggers like scroll, hover, or idle time, significantly improving LCP.
Expert Explanation:
A v17 feature that allows declaratively loading parts of a template based on triggers like scroll, hover, or idle time, significantly improving LCP.
How to use @defer with 'on viewport'?
AdvancedUsing {@defer on viewport} tells Angular only to load and render the block when it enters the browser's viewport.
Expert Explanation:
Using {@defer on viewport} tells Angular only to load and render the block when it enters the browser's viewport.
What is 'Zone-less' Angular?
AdvancedWith Signals, Angular can track exactly what changed, allowing apps to run without Zone.js, leading to smaller bundle sizes and predictable performanc...
Expert Explanation:
With Signals, Angular can track exactly what changed, allowing apps to run without Zone.js, leading to smaller bundle sizes and predictable performance.
Security: What is DomSanitizer?
AdvancedA service to sanitize values for use in HTML, preventing XSS. It helps trust specific parts of content using 'bypassSecurityTrustHtml'.
Expert Explanation:
A service to sanitize values for use in HTML, preventing XSS. It helps trust specific parts of content using 'bypassSecurityTrustHtml'.
What is Cross-Site Request Forgery (CSRF) protection in Angular?
AdvancedAngular's HttpClient provides built-in support for CSRF by reading a token from a cookie and sending it in a custom HTTP header.
Expert Explanation:
Angular's HttpClient provides built-in support for CSRF by reading a token from a cookie and sending it in a custom HTTP header.
Explain 'ViewContainerRef' for Dynamic UI.
AdvancedViewContainerRef represents a container where one or more views can be attached. It's the primary tool for custom directive logic and dynamic componen...
Expert Explanation:
ViewContainerRef represents a container where one or more views can be attached. It's the primary tool for custom directive logic and dynamic components.
What is 'Renderer2' and why prefer it over direct DOM access?
AdvancedRenderer2 is an abstraction over the DOM that ensures your code works even if the app runs in a different environment (e.g., Web Worker, SSR).
Expert Explanation:
Renderer2 is an abstraction over the DOM that ensures your code works even if the app runs in a different environment (e.g., Web Worker, SSR).
Web Workers in Angular: Why and How?
AdvancedCLI 'ng generate web-worker' creates a worker to run heavy CPU tasks on a separate thread, keeping the UI thread responsive.
Expert Explanation:
CLI 'ng generate web-worker' creates a worker to run heavy CPU tasks on a separate thread, keeping the UI thread responsive.
Explain 'Interceptors' with Metadata.
AdvancedInterceptors can use HttpContext to pass metadata (tokens) between the request origin and the interceptor for logic branching.
Expert Explanation:
Interceptors can use HttpContext to pass metadata (tokens) between the request origin and the interceptor for logic branching.
What is 'Route Reuse Strategy'?
AdvancedA class that determines if a component should be destroyed or cached and reused when a route changes (e.g., keeping search results alive).
Expert Explanation:
A class that determines if a component should be destroyed or cached and reused when a route changes (e.g., keeping search results alive).
How to perform 'Manual Hydration'?
AdvancedBefore v16, you used 'withServerTransition'. Now, you use 'provideClientHydration()' for the modern, non-destructive hydration.
Expert Explanation:
Before v16, you used 'withServerTransition'. Now, you use 'provideClientHydration()' for the modern, non-destructive hydration.
Angular Testing: Spectator Library.
AdvancedSpectator is a popular wrapper around Angular testing that reduces boilerplate and makes tests more readable compared to standard TestBed.
Expert Explanation:
Spectator is a popular wrapper around Angular testing that reduces boilerplate and makes tests more readable compared to standard TestBed.
Unit Testing: Component Harnesses.
AdvancedAn Angular Material concept now available to all, allowing you to interact with components in tests via an API that mimics user behavior.
Expert Explanation:
An Angular Material concept now available to all, allowing you to interact with components in tests via an API that mimics user behavior.
End-to-End Testing: Cypress vs Playwright.
AdvancedCypress is deeply integrated but has some limitations. Playwright is faster, supports multiple tabs, and is increasingly the standard for Angular E2E.
Expert Explanation:
Cypress is deeply integrated but has some limitations. Playwright is faster, supports multiple tabs, and is increasingly the standard for Angular E2E.
Explain 'InjectionContext' and 'runInInjectionContext'.
AdvancedA way to run functions that use 'inject()' outside of constructors or factory phases, useful for functional utilities.
Expert Explanation:
A way to run functions that use 'inject()' outside of constructors or factory phases, useful for functional utilities.
What is 'Environment Decorator' (@Injectable({providedIn: 'root'}))?
AdvancedIt allows the service to be tree-shaken if not used anywhere, optimizing the final production bundle.
Expert Explanation:
It allows the service to be tree-shaken if not used anywhere, optimizing the final production bundle.
Explain 'Input Transforms' (v16.1).
AdvancedIntroduced a way to transform @Input values automatically (e.g., booleanAttribute, numberAttribute) before they reach the component class.
Expert Explanation:
Introduced a way to transform @Input values automatically (e.g., booleanAttribute, numberAttribute) before they reach the component class.
What is 'Self', 'SkipSelf', 'Optional', and 'Host'?
AdvancedDI resolution modifiers. 'Self' limits to current injector; 'SkipSelf' starts from parent; 'Optional' returns null if missing; 'Host' stops at host el...
Expert Explanation:
DI resolution modifiers. 'Self' limits to current injector; 'SkipSelf' starts from parent; 'Optional' returns null if missing; 'Host' stops at host element.
Explain 'ForwardRef' in DI.
AdvancedA function that allows referring to a class not yet defined. Crucial for circular dependencies or recursive component configurations.
Expert Explanation:
A function that allows referring to a class not yet defined. Crucial for circular dependencies or recursive component configurations.
How to handle 'Custom Elements' (Angular Elements)?
AdvancedPackaging Angular components as standard Web Components that can be used in any HTML page or framework (Vue, React).
Expert Explanation:
Packaging Angular components as standard Web Components that can be used in any HTML page or framework (Vue, React).
Explain 'TemplateRef' vs 'ViewRef'.
AdvancedTemplateRef is a blueprint (defined in <ng-template>). ViewRef is the live instance of that template in the DOM.
Expert Explanation:
TemplateRef is a blueprint (defined in <ng-template>). ViewRef is the live instance of that template in the DOM.
What is the 'ModuleID' in older versions?
AdvancedUsed in CommonJS deployments for resolving relative URLs, now mostly obsolete in modern Webpack-based CLI builds.
Expert Explanation:
Used in CommonJS deployments for resolving relative URLs, now mostly obsolete in modern Webpack-based CLI builds.
Explain 'NgPlural' Directive.
AdvancedA structural directive that allows showing different templates based on numerical value (localization support).
Expert Explanation:
A structural directive that allows showing different templates based on numerical value (localization support).
Performance: 'ChangeDetectionStrategy.OnPush' deep dive.
AdvancedIt works by optimizing the change detector's 'dirty' check. It relies on object immutability. If a property of an object changes but not the reference...
Expert Explanation:
It works by optimizing the change detector's 'dirty' check. It relies on object immutability. If a property of an object changes but not the reference, UI won't update.
What is 'untracked' in Signals?
AdvancedA utility to read a signal's value without creating a reactive dependency in a 'computed' or 'effect' function.
Expert Explanation:
A utility to read a signal's value without creating a reactive dependency in a 'computed' or 'effect' function.
Explain 'take (1)' vs 'first ()'.
Advancedtake(1) takes the first emission and completes. first() takes the first emission matching a predicate and throws an error if none match.
Expert Explanation:
take(1) takes the first emission and completes. first() takes the first emission matching a predicate and throws an error if none match.
What is 'shareReplay' and its dangers?
AdvancedSaves the result of an API call to share with multiple subscribers. Danger: It can lead to memory leaks if 'refCount: true' isn't managed correctly.
Expert Explanation:
Saves the result of an API call to share with multiple subscribers. Danger: It can lead to memory leaks if 'refCount: true' isn't managed correctly.
Explain 'Router Link Active' directive.
AdvancedAdds a CSS class to an element when its router link is currently active, helping with navigation highlights.
Expert Explanation:
Adds a CSS class to an element when its router link is currently active, helping with navigation highlights.
What is 'Auxiliary Routes' (Named Outlets)?
AdvancedAllows having multiple side-by-side active routes by naming the router-outlets. Example: Dashboard and Chat popup simultaneously.
Expert Explanation:
Allows having multiple side-by-side active routes by naming the router-outlets. Example: Dashboard and Chat popup simultaneously.
Explain 'Route Matchers'.
AdvancedCustom logic to determine if a URL matches a route, allowing for complex URL patterns that static strings can't handle.
Expert Explanation:
Custom logic to determine if a URL matches a route, allowing for complex URL patterns that static strings can't handle.
Angular Security: Content Security Policy (CSP).
AdvancedConfiguring headers to restrict where scripts and resources can be loaded from. Angular supports CSP by avoiding eval() and inline scripts.
Expert Explanation:
Configuring headers to restrict where scripts and resources can be loaded from. Angular supports CSP by avoiding eval() and inline scripts.
Explain 'NgZone.run' vs 'NgZone.runOutsideAngular'.
Advancedrun() forces code back into the detection zone (used for 3rd party libs). runOutsideAngular() skips detection for high-freq events like 'mousemove'.
Expert Explanation:
run() forces code back into the detection zone (used for 3rd party libs). runOutsideAngular() skips detection for high-freq events like 'mousemove'.
What is 'ModuleWithProviders'?
AdvancedA pattern used to return a module along with its services, usually in 'forRoot()' methods (e.g., RouterModule.forRoot()).
Expert Explanation:
A pattern used to return a module along with its services, usually in 'forRoot()' methods (e.g., RouterModule.forRoot()).
Explain 'Embedded Views' vs 'Host Views'.
AdvancedEmbedded Views are created from TemplateRef (<ng-template>). Host Views are created when a component is instantiated.
Expert Explanation:
Embedded Views are created from TemplateRef (<ng-template>). Host Views are created when a component is instantiated.
How to handle 'Recursive Data' in templates?
AdvancedUsing a component that references itself in its own template, often combined with *ngIf to stop the recursion.
Expert Explanation:
Using a component that references itself in its own template, often combined with *ngIf to stop the recursion.
What is '@Attribute' decorator?
AdvancedA performance optimization that injects a static string value from the host element's attribute once, rather than tracking it via @Input.
Expert Explanation:
A performance optimization that injects a static string value from the host element's attribute once, rather than tracking it via @Input.
Explain 'KeyValueDiffers' service.
AdvancedA low-level service to track changes in objects or maps, useful when writing extremely complex custom directives.
Expert Explanation:
A low-level service to track changes in objects or maps, useful when writing extremely complex custom directives.
What is 'IterableDiffers'?
AdvancedTracks changes in arrays/iterables. It's what *ngFor uses internally to know what added/removed/moved.
Expert Explanation:
Tracks changes in arrays/iterables. It's what *ngFor uses internally to know what added/removed/moved.
Explain 'SecurityContext' in Sanitization.
AdvancedHTML, STYLE, SCRIPT, URL, and RESOURCE_URL are contexts that the sanitizer uses to apply different rules based on where data is injected.
Expert Explanation:
HTML, STYLE, SCRIPT, URL, and RESOURCE_URL are contexts that the sanitizer uses to apply different rules based on where data is injected.
How to use 'provideAnimations'? (v15+)
AdvancedIn standalone apps, use 'provideAnimations()' or 'provideNoopAnimations()' in the application providers array to enable/disable animations.
Expert Explanation:
In standalone apps, use 'provideAnimations()' or 'provideNoopAnimations()' in the application providers array to enable/disable animations.
What is 'ApplicationRef'?
AdvancedRepresents an instance of an Angular app on a page. Used to manually trigger tick() (full app check) or destroy the app.
Expert Explanation:
Represents an instance of an Angular app on a page. Used to manually trigger tick() (full app check) or destroy the app.
Explain 'ComponentRef' instance properties.
AdvancedAllows access to the component instance (change detection), location (DOM element), and injector of a dynamically created component.
Expert Explanation:
Allows access to the component instance (change detection), location (DOM element), and injector of a dynamically created component.
Implement a Writable Signal and Update it.
BeginnerSignals use .set() and .update().
Expert Explanation:
Signals use .set() and .update().
Code Example:
const count = signal(0);
count.set(5);
count.update(v => v + 1);Create a Computed Signal.
BeginnerDerived state from other signals.
Expert Explanation:
Derived state from other signals.
Code Example:
const double = computed(() => count() * 2);Fetch data using HttpClient and handle errors.
ExperienceUse catchError from RxJS.
Expert Explanation:
Use catchError from RxJS.
Code Example:
this.http.get('/api/data').pipe(
catchError(err => of([]))
).subscribe(res => this.data = res);Implement a Reactive Form with Validation.
BeginnerFormGroup and Validators.
Expert Explanation:
FormGroup and Validators.
Code Example:
form = new FormGroup({
email: new FormControl('', [Validators.required, Validators.email])
});Implement a simple Directive for Hover Effect.
Experience@HostListener for events.
Expert Explanation:
@HostListener for events.
Code Example:
@Directive({ selector: '[appHover]' })
export class Hover {
@HostListener('mouseenter') onEnter() { ... }
}Create a Custom Pipe to Reverse String.
BeginnerImplement PipeTransform.
Expert Explanation:
Implement PipeTransform.
Code Example:
transform(val: string): string {
return val.split('').reverse().join('');
}Use 'switchMap' for Search Logic.
ExperiencePrevents race conditions.
Expert Explanation:
Prevents race conditions.
Code Example:
results$ = searchTerm$.pipe(
switchMap(term => this.service.search(term))
);Dynamic Component Injection (v13+).
AdvancedUse ViewContainerRef and createComponent.
Expert Explanation:
Use ViewContainerRef and createComponent.
Code Example:
this.vcr.createComponent(MyComponent);Implement a Route Guard (Functional).
ExperienceModern Angular uses functions for guards.
Expert Explanation:
Modern Angular uses functions for guards.
Code Example:
export const authGuard: CanActivateFn = (route, state) => {
return inject(AuthService).isLoggedIn();
};Combine multiple Observables together.
ExperienceforkJoin emits when all complete.
Expert Explanation:
forkJoin emits when all complete.
Code Example:
forkJoin({ a: obs1, b: obs2 }).subscribe(data => ...);Implement a Debounce Search.
BeginnerUse debounceTime operator.
Expert Explanation:
Use debounceTime operator.
Code Example:
input$.pipe(debounceTime(300), distinctUntilChanged());Create a Singleton Service.
BeginnerprovidedIn: 'root'.
Expert Explanation:
providedIn: 'root'.
Code Example:
@Injectable({ providedIn: 'root' })Handle Multiple Async Pipes.
ExperienceUse 'as' in *ngIf.
Expert Explanation:
Use 'as' in *ngIf.
Code Example:
<div *ngIf="data$ | async as data"> {{data.name}} </div>Implement a custom form validator.
ExperienceFunction returning ValidatorFn.
Expert Explanation:
Function returning ValidatorFn.
Code Example:
function myVal(c: FormControl) {
return c.value === 'bad' ? { invalid: true } : null;
}Use trackBy in *ngFor.
BeginnerOptimization for lists.
Expert Explanation:
Optimization for lists.
Code Example:
trackById(idx, item) { return item.id; }Navigate programmatically with Router.
BeginnerInject Router service.
Expert Explanation:
Inject Router service.
Code Example:
this.router.navigate(['/items', id]);Capture Route Parameters.
BeginnerActivatedRoute snapshot or observable.
Expert Explanation:
ActivatedRoute snapshot or observable.
Code Example:
id = this.route.snapshot.paramMap.get('id');Create a behavior subject for state shared.
BeginnerState management simple.
Expert Explanation:
State management simple.
Code Example:
user$ = new BehaviorSubject<User>(null);Use 'takeUntil' for cleanup.
ExperienceStandard unsubscribe pattern.
Expert Explanation:
Standard unsubscribe pattern.
Code Example:
obs$.pipe(takeUntil(this.destroy$)).subscribe();Lazy load a component manually.
AdvancedDynamic import.
Expert Explanation:
Dynamic import.
Code Example:
const { MyComp } = await import('./my.comp');Implement an HTTP Interceptor.
ExperienceAuth headers.
Expert Explanation:
Auth headers.
Code Example:
intercept(req, next) { const cloned = req.clone(...); return next.handle(cloned); }Convert Observable to Signal.
ExperiencetoSignal() utility.
Expert Explanation:
toSignal() utility.
Code Example:
const data = toSignal(this.http.get(...));Convert Signal to Observable.
ExperiencetoObservable() utility.
Expert Explanation:
toObservable() utility.
Code Example:
const val$ = toObservable(this.mySignal);Implement Signal effect.
BeginnerWatch changes.
Expert Explanation:
Watch changes.
Code Example:
effect(() => console.log('Changed:', this.mySignal()));Global Error Handler.
AdvancedImplement ErrorHandler class.
Expert Explanation:
Implement ErrorHandler class.
Code Example:
handleError(err) { // logs to server }Input Transform (Boolean).
ExperienceAuto conversion.
Expert Explanation:
Auto conversion.
Code Example:
@Input({ transform: booleanAttribute }) disabled: boolean = false;Signal equality function.
AdvancedCustom comparator.
Expert Explanation:
Custom comparator.
Code Example:
count = signal(initial, { equal: (a, b) => a.id === b.id });Signal 'update' with object mutate.
ExperienceNote: mutate() is removed, use update().
Expert Explanation:
Note: mutate() is removed, use update().
Code Example:
state.update(s => ({...s, name: 'New'}));Access @ViewChild DOM element.
BeginnerElementRef access.
Expert Explanation:
ElementRef access.
Code Example:
@ViewChild('myDiv') div!: ElementRef;NgFor object properties.
BeginnerKeyValue pipe.
Expert Explanation:
KeyValue pipe.
Code Example:
*ngFor="let item of myObj | keyvalue"Sort array using pipe.
ExperienceOrderBy logic.
Expert Explanation:
OrderBy logic.
Code Example:
transform(arr) { return arr.sort((a,b) => ...); }Signal based form binding.
AdvancedExperimental/Custom.
Expert Explanation:
Experimental/Custom.
Code Example:
this.form.valueChanges.subscribe(v => mySignal.set(v));Handle route change event.
ExperienceRouter events.
Expert Explanation:
Router events.
Code Example:
router.events.pipe(filter(e => e instanceof NavigationEnd))Custom structural directive.
AdvancedTemplateRef/ViewContainer.
Expert Explanation:
TemplateRef/ViewContainer.
Code Example:
if (cond) { this.vcr.createEmbeddedView(this.tr); }Access Host element attributes.
Experience@Attribute injection.
Expert Explanation:
@Attribute injection.
Code Example:
constructor(@Attribute('type') type: string) {}Implement infinite scroll logic.
AdvancedIntersection Observer.
Expert Explanation:
Intersection Observer.
Code Example:
obs.observe(el); ... onIntersect() { fetchNext(); }Caching HTTP requests.
ExperienceMap and of.
Expert Explanation:
Map and of.
Code Example:
if (cache) return of(cache); return http.get().pipe(tap(r => cache = r));NgRx Action and Reducer.
ExperienceState management.
Expert Explanation:
State management.
Code Example:
on(Action, (state) => ({ ...state, val: 1 }))NgRx Selector.
ExperienceMemoized data.
Expert Explanation:
Memoized data.
Code Example:
createSelector(feature, s => s.items)Unit Test a Service.
BeginnerTestBed usage.
Expert Explanation:
TestBed usage.
Code Example:
service = TestBed.inject(MyService); expect(service).toBeTruthy();Mock an HTTP call in tests.
ExperienceHttpClientTestingModule.
Expert Explanation:
HttpClientTestingModule.
Code Example:
httpMock.expectOne('/api').flush(mockRes);Test a component with @Input.
BeginnerSet property.
Expert Explanation:
Set property.
Code Example:
component.myInput = 'test'; fixture.detectChanges();Trigger click event in unit test.
BeginnerNative element click.
Expert Explanation:
Native element click.
Code Example:
el.nativeElement.click(); fixture.detectChanges();Standalone route configuration.
ExperienceRoute array.
Expert Explanation:
Route array.
Code Example:
providers: [provideRouter(ROUTES)]Environment variable access.
BeginnerEnvironment file.
Expert Explanation:
Environment file.
Code Example:
import { environment } from './env';Dynamic Meta Tags.
ExperienceMeta service.
Expert Explanation:
Meta service.
Code Example:
this.meta.updateTag({ name: 'desc', content: '...' });Update Title programmatically.
BeginnerTitle service.
Expert Explanation:
Title service.
Code Example:
this.title.setTitle('New Title');Signal inside a Service.
BeginnerReactive state.
Expert Explanation:
Reactive state.
Code Example:
export class Service { count = signal(0); }Recursive Route children.
AdvancedSelf reference.
Expert Explanation:
Self reference.
Code Example:
path: 'dir', children: [ { path: '**', component: Dir } ]Conditional polyfill loading.
AdvancedDynamic import in main.ts.
Expert Explanation:
Dynamic import in main.ts.
Code Example:
if (!window.Intl) await import('intl');