Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Unsubscribe from Observables using: takeUntil with a destroy notifier. async pipe which auto-unsubscribes. Remove event listeners added manually. Avoid retaining references to DOM or large objects. Use tool…
Short answer: Angular uses NgZone to detect asynchronous events (like clicks, timers, HTTP). NgZone runs code inside Angular's zone, triggering change detection automatically. You can run code outside Angular's zone to p…
Short answer: Create a validator function returning an error object or null. Explain a bit more ✅ Example (Custom validator checking forbidden name): function forbiddenNameValidator(nameRe: RegExp): ValidatorFn { return…
Short answer: Name some commonly used decorators. Decorators are functions that add metadata to classes, methods, or properties. Common Angular Decorators: Decorator Description @Componen Declares a component @NgModule D…
Short answer: Applications? Unsubscribe from Observables using: takeUntil with a destroy notifier. async pipe which auto-unsubscribes. Remove event listeners added manually. Avoid retaining references to DOM or large obj…
Short answer: @ngrx/store provides a Redux-style store implementation. It holds the application state as a single immutable object. Provides selectors to access state slices. Dispatches actions to modify the state via re…
Short answer: Use async/await with Angular's waitForAsync or Jasmine’s done callback. Use Angular’s fakeAsync and tick() to simulate asynchronous passage of time. Example with fakeAsync: it('should fetch data asynchronou…
Short answer: angular.json is the workspace configuration file. Defines project settings including: Build and serve options File assets Environment configurations Output paths Third-party library styles and scripts Contr…
Short answer: Lazy loading delays loading feature modules until the user navigates to their route. Implemented with the router using loadChildren and dynamic imports. Example code const routes: Routes = [ { path: 'admin'…
Short answer: utomatically. You can run code outside Angular's zone to prevent unnecessary change detection. ✅ constructor(private ngZone: NgZone) {} runHeavyTaskOutsideAngular() { this.ngZone.runOutsideAngular(() =>…
Short answer: ngular? Create a validator function returning an error object or null. ✅ Example (Custom validator checking forbidden name): function forbiddenNameValidator(nameRe: RegExp): ValidatorFn { return (control: A…
Short answer: decorators. Decorators are functions that add metadata to classes, methods, or properties. Common Angular Decorators: Decorator Description @Componen Declares a component @NgModule Declares a module @Inject…
Short answer: Memoization: A technique to cache the results of expensive function calls and return the cached result when inputs are the same. Explain a bit more How it helps: Avoids recalculating heavy operations on eve…
Short answer: Use Async Validators returning Observable<ValidationErrors | null>. ✅ Example code function uniqueUsernameValidator(service: UserService): AsyncValidatorFn { return (control: AbstractControl): Observa…
Short answer: Pipes transform data in templates. Used with the pipe | operator. Angular provides built-in pipes like date, currency, uppercase, async, etc. Example code <p>{{ birthday | date:'longDate' }}</p>…
Short answer: Use HttpClientTestingModule and HttpTestingController to mock and control HTTP requests. Example code beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule] }); httpTestin…
Short answer: Angular CLI supports custom builders to extend build behavior. Create a Node.js package implementing the Builder interface. Define builder options and logic in a builders.json. Use the custom builder in ang…
Short answer: Used mainly by feature modules that provide services and routes. forRoot() configures and provides singleton services for the app. Usually called in the root module. forChild() configures child routes witho…
Short answer: ngular for performance improvement? Memoization: technique to cache the results of expensive function calls and return the cached result when inputs are the same. ngular for performance improvement? Memoiza…
Short answer: synchronously in Angular? Use Async Validators returning Observable<ValidationErrors | null>. ✅ function uniqueUsernameValidator(service: UserService): syncValidatorFn { return (control: AbstractContr…
Short answer: A component is the building block of Angular apps. Each component controls a part of the UI. A component includes: TypeScript class HTML template CSS styles Example code @Component({ selector: 'app-login',…
Short answer: Implement a global error handler by extending Angular’s ErrorHandler class: @Injectable() export class GlobalErrorHandler implements ErrorHandler { handleError(error: any) { // log to server or show user no…
Short answer: spyOn() creates a spy on a method, allowing you to track calls and override behavior. Example code spyOn(service, 'getData').and.returnValue(of(['mock data'])); Useful for mocking service methods and verify…
Short answer: RouterModule provides Angular’s routing functionality. Import it to define routes and use routing directives like [routerLink] and <router-outlet>. It configures navigation and URL handling in the app…
Short answer: pplication? Implement a global error handler by extending Angular’s ErrorHandler class: @Injectable() export class GlobalErrorHandler implements ErrorHandler { handleError(error: any) { // log to server or…
Angular Angular Tutorial · Angular
Short answer: Unsubscribe from Observables using: takeUntil with a destroy notifier. async pipe which auto-unsubscribes. Remove event listeners added manually. Avoid retaining references to DOM or large objects. Use tools like Chrome DevTools and Angular Profiler.
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: Angular uses NgZone to detect asynchronous events (like clicks, timers, HTTP). NgZone runs code inside Angular's zone, triggering change detection automatically. You can run code outside Angular's zone to prevent unnecessary change detection. ✅
constructor(private ngZone: NgZone) {} runHeavyTaskOutsideAngular() { this.ngZone.runOutsideAngular(() => { // code here won't trigger change detection }); }
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: Create a validator function returning an error object or null.
✅ Example (Custom validator checking forbidden name): function forbiddenNameValidator(nameRe: RegExp): ValidatorFn { return (control: AbstractControl): ValidationErrors | null => { const forbidden = nameRe.test(control.value); return forbidden ? { forbiddenName: { value: control.value } } : null; }; } // Usage: new FormControl('', [forbiddenNameValidator(/admin/i)])
Create a validator function returning an error object or null. ✅ Example (Custom validator checking forbidden name): function forbiddenNameValidator(nameRe: RegExp): ValidatorFn { return (control: AbstractControl): ValidationErrors | null => {
const forbidden = nameRe.test(control.value);
return forbidden ? { forbiddenName: { value: control.value } } : null; }; } // Usage: new FormControl('', [forbiddenNameValidator(/admin/i)])
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: Name some commonly used decorators. Decorators are functions that add metadata to classes, methods, or properties. Common Angular Decorators: Decorator Description @Componen Declares a component @NgModule Declares a module @Injectab le Declares a service for DI @Input() Pass data from parent to child @Output() Emit events from child to parent @Directiv Create custom directives
@Component({ selector: 'app-header', templateUrl: './header.component.html' }) Real-Time Example: Use @Input() in a product card to pass product details from a parent ProductListComponent.
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: Applications? Unsubscribe from Observables using: takeUntil with a destroy notifier. async pipe which auto-unsubscribes. Remove event listeners added manually. Avoid retaining references to DOM or large objects. Use tools like Chrome DevTools and Angular Profiler.
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: @ngrx/store provides a Redux-style store implementation. It holds the application state as a single immutable object. Provides selectors to access state slices. Dispatches actions to modify the state via reducers.
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: Use async/await with Angular's waitForAsync or Jasmine’s done callback. Use Angular’s fakeAsync and tick() to simulate asynchronous passage of time. Example with fakeAsync: it('should fetch data asynchronously', fakeAsync(() => { let data; service.getData().subscribe(result => data = result); tick(); // simulate async time passing expect(data).toEqual(['expected data']); }));
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: angular.json is the workspace configuration file. Defines project settings including: Build and serve options File assets Environment configurations Output paths Third-party library styles and scripts Controls how Angular CLI builds and serves your app.
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: Lazy loading delays loading feature modules until the user navigates to their route. Implemented with the router using loadChildren and dynamic imports.
const routes: Routes = [ { path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule) } ]; This reduces initial bundle size and improves app startup time.
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: utomatically. You can run code outside Angular's zone to prevent unnecessary change detection. ✅ constructor(private ngZone: NgZone) {} runHeavyTaskOutsideAngular() { this.ngZone.runOutsideAngular(() => { // code here won't trigger change detection }); } utomatically. You can run code outside Angular's zone to prevent… unnecessary change detection.… ✅
constructor(private ngZone: NgZone) {} runHeavyTaskOutsideAngular() { this.ngZone.runOutsideAngular(() => { // code here won't trigger change detection }); } utomatically. You can run code outside Angular's zone to prevent unnecessary change detection. ✅ Example: constructor(private ngZone: NgZone) {} runHeavyTaskOutsideAngular() { this.ngZone.runOutsideAngular(() => { // code here won't trigger change detection }); } utomatically. You can run code outside Angular's zone to prevent… unnecessary change detection. ✅ Example: constructor(private ngZone: NgZone) {} runHeavyTaskOutsideAngular() { this.ngZone.runOutsideAngular(() => { // code here won't trigger change detection }); }
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: ngular? Create a validator function returning an error object or null. ✅ Example (Custom validator checking forbidden name): function forbiddenNameValidator(nameRe: RegExp): ValidatorFn { return (control: AbstractControl): ValidationErrors | null => { const forbidden = nameRe.test(control.value); return forbidden ? { forbiddenName: { value:… control.value…… }… ngular? ngular? Create a validator function returning an…
error object or null. ✅ Example (Custom validator checking forbidden name): function forbiddenNameValidator(nameRe: RegExp): ValidatorFn { return (control: AbstractControl): ValidationErrors | null => { const forbidden = nameRe.test(control.value); return forbidden ? { forbiddenName: { value: control.value }… ngular? Create a validator function returning an error object or null. ✅ Example (Custom validator checking forbidden name): function forbiddenNameValidator(nameRe: RegExp): ValidatorFn { return (control: AbstractControl): ValidationErrors | null => { const forbidden = nameRe.test(control.value); return forbidden ? {… ngular?… const forbidden = nameRe.test(control.value);
return forbidden ? { forbiddenName: { value: control.value } } : null; }; } // Usage: new FormControl('', [forbiddenNameValidator(/admin/i)])
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: decorators. Decorators are functions that add metadata to classes, methods, or properties. Common Angular Decorators: Decorator Description @Componen Declares a component @NgModule Declares a module @Injectab le Declares a service for DI @Input() Pass data from parent to child @Output() Emit events from child to parent @Directiv Create custom… directives…… @Component({ selector: 'app-header', templateUrl:…
Use @Input() in a product card to pass product details from a parent ProductListComponent.
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: Memoization: A technique to cache the results of expensive function calls and return the cached result when inputs are the same.
How it helps: Avoids recalculating heavy operations on every change detection. Improves performance for pure functions or selectors. ✅ Example in Angular: const memoizedFunction = memoize((input) => { // expensive calculation return result; }); this.result = memoizedFunction(input); You can use libraries like lodash's _.memoize or write your own. Angular Module System
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: Use Async Validators returning Observable<ValidationErrors | null>. ✅
function uniqueUsernameValidator(service: UserService): AsyncValidatorFn { return (control: AbstractControl): Observable<ValidationErrors | null> => { return service.checkUsername(control.value).pipe( map(isTaken => (isTaken ? { uniqueUsername: true } : null)) ); }; } // Usage: new FormControl('', null, uniqueUsernameValidator(this.userService));
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: Pipes transform data in templates. Used with the pipe | operator. Angular provides built-in pipes like date, currency, uppercase, async, etc.
<p>{{ birthday | date:'longDate' }}</p>
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: Use HttpClientTestingModule and HttpTestingController to mock and control HTTP requests.
beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule] }); httpTestingController = TestBed.inject(HttpTestingController); }); it('should call GET API', () => { service.getData().subscribe(data => { expect(data).toEqual(mockData); }); const req = httpTestingController.expectOne('api/data'); expect(req.request.method).toBe('GET'); req.flush(mockData); httpTestingController.verify(); });
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: Angular CLI supports custom builders to extend build behavior. Create a Node.js package implementing the Builder interface. Define builder options and logic in a builders.json. Use the custom builder in angular.json for build or serve targets. Use case: Customized builds, code analysis, or special deployment pipelines.
Angular Angular Tutorial · Angular
Short answer: Used mainly by feature modules that provide services and routes. forRoot() configures and provides singleton services for the app. Usually called in the root module. forChild() configures child routes without providing new service instances.
RouterModule.forRoot(routes) // for root app routing RouterModule.forChild(childRoutes) // for feature module routing
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: ngular for performance improvement? Memoization: technique to cache the results of expensive function calls and return the cached result when inputs are the same. ngular for performance improvement? Memoization: technique to cache the results of expensive function calls and return the cached result when inputs are the same. How it helps: Avoids…… recalculating heavy operations on every change detection.
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: synchronously in Angular? Use Async Validators returning Observable<ValidationErrors | null>. ✅ function uniqueUsernameValidator(service: UserService): syncValidatorFn { return (control: AbstractControl): Observable<ValidationErrors | null> => { return service.checkUsername(control.value).pipe( map(isTaken => (isTaken ? {… uniqueUsername: true } :…… null)) ); }; } // Usage: new FormControl('', null,…
uniqueUsernameValidator(this.userService)); synchronously in Angular? synchronously in Angular? Use Async Validators returning Observable<ValidationErrors | null>. ✅
function uniqueUsernameValidator(service: UserService): syncValidatorFn { return (control: AbstractControl): Observable<ValidationErrors | null> => { return service.checkUsername(control.value).pipe( map(isTaken => (isTaken ? {… uniqueUsername: true } :… null)) ); }; } // Usage: new FormControl('', null, uniqueUsernameValidator(this.userService)); synchronously in Angular? synchronously in Angular? Use Async Validators returning Observable<ValidationErrors | null>. ✅ Example: function uniqueUsernameValidator(service: UserService): syncValidatorFn { return (control: AbstractControl): Observable<ValidationErrors | null> => { return service.checkUsername(control.value).pipe( map(isTaken => (isTaken ? { uniqueUsername: true } :… null)) ); }; } // Usage: new FormControl('', null, uniqueUsernameValidator(this.userService)); synchronously in Angular? Use Async Validators returning Observable<ValidationErrors | null>. ✅ Example: function uniqueUsernameValidator(service: UserService): syncValidatorFn { return (control: AbstractControl): Observable<ValidationErrors | null> => { return service.checkUsername(control.value).pipe( map(isTaken => (isTaken ? { uniqueUsername: true } : null)) ); }; } // Usage: new FormControl('', null, uniqueUsernameValidator(this.userService));
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: A component is the building block of Angular apps. Each component controls a part of the UI. A component includes: TypeScript class HTML template CSS styles
@Component({ selector: 'app-login', templateUrl: './login.component.html', styleUrls: ['./login.component.css'] }) export class LoginComponent { // logic here } Real-Time Example: In a ride-sharing app: LoginComponent handles user login. MapComponent shows real-time driver locations.
ShopNest’s ProductListComponent binds *ngFor to products and uses (click) to add to cart.
Angular Angular Tutorial · Angular
Short answer: Implement a global error handler by extending Angular’s ErrorHandler class: @Injectable() export class GlobalErrorHandler implements ErrorHandler { handleError(error: any) { // log to server or show user notification console.error('Global error:', error); } } Provide it in your AppModule: providers: [{ provide: ErrorHandler, useClass: GlobalErrorHandler }] Can also use HTTP interceptors to catch API errors.
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: spyOn() creates a spy on a method, allowing you to track calls and override behavior.
spyOn(service, 'getData').and.returnValue(of(['mock data'])); Useful for mocking service methods and verifying interactions.
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: RouterModule provides Angular’s routing functionality. Import it to define routes and use routing directives like [routerLink] and <router-outlet>. It configures navigation and URL handling in the app. Angular CLI & Build System
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.
Angular Angular Tutorial · Angular
Short answer: pplication? Implement a global error handler by extending Angular’s ErrorHandler class: @Injectable() export class GlobalErrorHandler implements ErrorHandler { handleError(error: any) { // log to server or show user notification console.error('Global error:', error); } } Provide it in your AppModule: providers: [{ provide: ErrorHandler,… useClass:……… pplication? pplication? Implement a global error handler by…
extending Angular’s ErrorHandler class: @Injectable() export class GlobalErrorHandler implements ErrorHandler { handleError(error: any) { // log to server or show user notification console.error('Global error:', error); } } Provide it in your AppModule: providers: [{ provide: ErrorHandler, useClass:… pplication? Implement a global error handler by extending Angular’s ErrorHandler class: @Injectable() export class GlobalErrorHandler implements ErrorHandler { handleError(error: any) { // log to server or show user notification console.error('Global error:', error); } } Provide it in your AppModule: providers: [{ provide:… pplication?…
ShopNest admin can be built in Angular with modules/components, services for API calls, and reactive forms for product edit.