Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Use built-in validators via HTML attributes like required, minlength. Use Angular directives like #username="ngModel" to check validity. ✅ Example code <input name="email" ngModel req…
Short answer: And configuration to manage navigation between views. Explain a bit more ✅ Imports in App: import { RouterModule } from '@angular/router'; You use it with RouterModule.forRoot() (for root module) or RouterM…
Short answer: Examples: <!-- *ngIf --> <div *ngIf="user.isLoggedIn">Welcome, {{ user.name }}</div> <!-- *ngFor --> <li *ngFor="let item of items">{{ item }}</li> Re…
Short answer: Directives are instructions in the DOM. They help Angular extend HTML's capabilities. Types of Directives: Real-world example (ShopNest) A shared CartService is injected into header and product pages so bot…
Short answer: XSS (Cross-Site Scripting) Protection: Angular automatically sanitizes dangerous content in templates (e.g., {{ userInput }}). Explain a bit more Use DomSanitizer for trusted content. Binding syntax prevent…
Short answer: Provide a mock implementation of the service in TestBed using the providers array. Use useClass, useValue, or useFactory to inject mocks. Example code class MockDataService { getData() { return of(['mock da…
Short answer: gainst XSS and CSRF? XSS (Cross-Site Scripting) Protection: Angular automatically sanitizes dangerous content in templates (e.g., {{ userInput }}). Use DomSanitizer for trusted content. Binding syntax preve…
Short answer: rray. Use useClass, useValue, or useFactory to inject mocks. class MockDataService { getData() { return of(['mock data']); } } beforeEach(() => { TestBed.configureTestingModule({ providers: [{ provide: D…
Short answer: Use Ahead-of-Time (AOT) compilation for faster rendering. Explain a bit more Enable production builds (ng build --prod) with optimizations: Minification Tree shaking Dead code elimination Use lazy loading f…
Short answer: And faster repeat loads. Optimize images and assets (compress, lazy load). Use OnPush change detection for components to reduce unnecessary UI updates. Avoid memory leaks by unsubscribing from observables.…
Short answer: NgRx is a Redux-inspired state management library for Angular. Uses Actions, Reducers, Store, and Effects to handle application state predictably. Centralizes state for easy debugging, time-travel, and immu…
Short answer: Use the production flag with ng build: ng build --prod This enables: AOT compilation (Ahead-of-Time) Minification and Uglification of code Tree shaking to remove unused code Bundling for fewer HTTP requests…
Short answer: ChangeDetectorRef allows you to manually control change detection: detectChanges(): Run change detection immediately. markForCheck(): Mark component to check in next cycle. detach(): Stop change detection f…
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: 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: 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: 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: 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: 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…
Angular Angular Tutorial · Angular
Short answer: Use built-in validators via HTML attributes like required, minlength. Use Angular directives like #username="ngModel" to check validity. ✅
<input name="email" ngModel required email #email="ngModel" /> <div *ngIf="email.invalid && email.touched"> <small *ngIf="email.errors?.required">Email is required</small> <small *ngIf="email.errors?.email">Invalid email format</small> </div>
ShopNest’s ProductListComponent binds *ngFor to products and uses (click) to add to cart.
Angular Angular Tutorial · Angular
Short answer: And configuration to manage navigation between views.
✅ Imports in App: import { RouterModule } from '@angular/router'; You use it with RouterModule.forRoot() (for root module) or RouterModule.forChild() (for feature modules with lazy loading). const routes: Routes = [ { path: '', component: HomeComponent }, { path: 'products', component: ProductListComponent }, { path: 'products/:id', component: ProductDetailComponent }, { path: '**', component: NotFoundComponent } // wildcard route ]; Tools for Managing Routes: Route Guards Route Parameters Lazy Loading Query Params Nested Routes implemented? 🔸 Lazy Loading: Lazy loading is a technique to load feature modules only when needed, improving initial load performance. ✅ Implementation:
ShopNest’s ProductListComponent binds *ngFor to products and uses (click) to add to cart.
Angular Angular Tutorial · Angular
Short answer: Examples: <!-- *ngIf --> <div *ngIf="user.isLoggedIn">Welcome, {{ user.name }}</div> <!-- *ngFor --> <li *ngFor="let item of items">{{ item }}</li> Real-Time Example: In a to-do app, *ngFor is used to loop through tasks and display them.
A shared CartService is injected into header and product pages so both see the same cart count.
Angular Angular Tutorial · Angular
Short answer: Directives are instructions in the DOM. They help Angular extend HTML's capabilities. Types of Directives:
A shared CartService is injected into header and product pages so both see the same cart count.
Angular Angular Tutorial · Angular
Short answer: XSS (Cross-Site Scripting) Protection: Angular automatically sanitizes dangerous content in templates (e.g., {{ userInput }}).
Use DomSanitizer for trusted content. Binding syntax prevents direct HTML injection. CSRF (Cross-Site Request Forgery) Protection: Angular’s HttpClient works with backend CSRF tokens. Common approach: Backend sends CSRF token, Angular sends it back via headers or cookies. Developers must implement token handling in interceptors.
Angular Angular Tutorial · Angular
Short answer: Provide a mock implementation of the service in TestBed using the providers array. Use useClass, useValue, or useFactory to inject mocks.
class MockDataService { getData() { return of(['mock data']); } } beforeEach(() => { TestBed.configureTestingModule({ providers: [{ provide: DataService, useClass: MockDataService }] }); });
A shared CartService is injected into header and product pages so both see the same cart count.
Angular Angular Tutorial · Angular
Short answer: gainst XSS and CSRF? XSS (Cross-Site Scripting) Protection: Angular automatically sanitizes dangerous content in templates (e.g., {{ userInput }}). Use DomSanitizer for trusted content. Binding syntax prevents direct HTML injection. CSRF (Cross-Site Request Forgery) Protection: Angular’s HttpClient works with backend CSRF tokens. Common… approach: Backend……… sends CSRF token, Angular sends it back via headers or…
cookies. Developers must implement token handling in interceptors.
Angular Angular Tutorial · Angular
Short answer: rray. Use useClass, useValue, or useFactory to inject mocks. class MockDataService { getData() { return of(['mock data']); } } beforeEach(() => { TestBed.configureTestingModule({ providers: [{ provide: DataService, useClass: MockDataService }] }); }); rray. Use useClass, useValue, or useFactory to inject mocks.
… class MockDataService {… getData() { return of(['mock data']); } } beforeEach(() => { TestBed.configureTestingModule({ providers: [{ provide: DataService, useClass: MockDataService }] }); }); rray. Use useClass, useValue, or useFactory to inject mocks. Example: class MockDataService { getData() { return of(['mock data']); } } beforeEach(() => { TestBed.configureTestingModule({ providers: [{ provide: DataService, useClass: MockDataService }] }); }); rray. Use useClass, useValue, or useFactory to inject mocks. Example:… class MockDataService { getData() { return of(['mock data']); } } beforeEach(() => { TestBed.configureTestingModule({ providers: [{ provide: DataService, useClass: MockDataService }] }); });
A shared CartService is injected into header and product pages so both see the same cart count.
Angular Angular Tutorial · Angular
Short answer: Use Ahead-of-Time (AOT) compilation for faster rendering.
Enable production builds (ng build --prod) with optimizations: Minification Tree shaking Dead code elimination Use lazy loading for feature modules. Bundle analysis: Use tools like source-map-explorer to find large bundles. Use Angular’s built-in caching and service workers (via Angular PWA) for offline and faster repeat loads. Optimize images and assets (compress, lazy load). Use OnPush change detection for components to reduce unnecessary UI updates. Avoid memory leaks by unsubscribing from observables. Use trackBy function with *ngFor to optimize DOM updates.
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: And faster repeat loads. Optimize images and assets (compress, lazy load). Use OnPush change detection for components to reduce unnecessary UI updates. Avoid memory leaks by unsubscribing from observables. Use trackBy function with *ngFor to optimize DOM updates.
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 is a Redux-inspired state management library for Angular. Uses Actions, Reducers, Store, and Effects to handle application state predictably. Centralizes state for easy debugging, time-travel, and immutability. Ideal for complex apps requiring consistent global state management.
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 the production flag with ng build: ng build --prod This enables: AOT compilation (Ahead-of-Time) Minification and Uglification of code Tree shaking to remove unused code Bundling for fewer HTTP requests Enables optimizations in angular.json
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: ChangeDetectorRef allows you to manually control change detection: detectChanges(): Run change detection immediately. markForCheck(): Mark component to check in next cycle. detach(): Stop change detection for component. reattach(): Resume change detection. ✅
constructor(private cd: ChangeDetectorRef) {} updateData() { this.data = fetchNewData(); this.cd.detectChanges(); // manually trigger update }
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: 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: 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: 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: 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: 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: 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.
Install Toolliyo like an app Free
Home-screen access to tutorials, coding practice & career tools — no app store needed.
On iPhone/iPad: tap Share then Add to Home Screen.