Skip to content

Angular Developer interview questions

100 real questions with model answers and explanations for Junior Angular Developer candidates.

See a Angular Developer resume example

Practice with flashcards

Spaced repetition · Hunter Pass

Questions

componentsangular

An Angular component is a class that controls a reusable part of the user interface.

  • Its template describes the HTML Angular renders.
  • Its class stores data and methods used by that template.
  • The @Component decorator connects the class to its selector, template, styles, and dependencies.

Why interviewers ask this: The interviewer checks whether you understand the basic unit from which Angular interfaces are built.

componentsdecorators

The @Component decorator supplies Angular with the metadata needed to create and render a component.

  • selector identifies the component in another template.
  • template or templateUrl defines its view, while styles or styleUrl defines local styles.
  • imports lists template dependencies when the component is standalone.

Why interviewers ask this: A strong answer identifies @Component as framework metadata and names its main responsibilities.

componentsangular

A component selector is a CSS selector Angular matches to a host element when it creates that component.

  • A selector such as app-profile is used as an HTML element in a parent template.
  • Angular creates the component instance and renders its view inside the matched host element.
  • A unique, prefixed element selector helps avoid collisions with native HTML elements.

Why interviewers ask this: The interviewer evaluates whether you know how a component is referenced and instantiated in templates.

templates

An inline template lives in the component metadata, while templateUrl points to a separate HTML file.

  • The template property suits a very small view written directly in the TypeScript file.
  • templateUrl keeps larger markup separate and easier to read.
  • Both forms are compiled as the component view and support the same Angular template syntax.

Why interviewers ask this: This checks whether you understand the two standard ways to define a component view.

componentsangulartemplates

A template can read accessible component fields and call component methods through its binding context.

  • Interpolation and property binding read values from the class.
  • Event binding can invoke a method or update a field.
  • Template expressions should stay simple because Angular evaluates them while updating the view.

Why interviewers ask this: The interviewer checks whether you understand the connection between a component's view and its class.

angulartemplates

Interpolation renders the string value of a template expression between double curly braces.

  • A binding such as {{ userName }} reads userName from the component context.
  • Angular updates the displayed text when the bound value changes.
  • Interpolation is intended for text content and string-valued bindings, not event handling.

Why interviewers ask this: This tests whether you can explain Angular's simplest form of one-way data binding.

angular

Property binding sends a value from a component expression to a DOM, directive, or child component property.

  • Square brackets mark the target property, as in [disabled]="isSaving".
  • Angular preserves the expression's value type instead of converting everything to text.
  • The view receives new values whenever Angular detects a relevant state change.

Why interviewers ask this: The interviewer wants to see that you understand one-way binding from component state to a target property.

angular

Property binding updates an object property, while attribute binding writes an HTML attribute value.

  • [value] targets the live value property of an input element.
  • [attr.aria-label] targets an attribute that may not have a matching DOM property.
  • Setting an attribute binding to null removes that attribute.

Why interviewers ask this: A strong answer distinguishes initial HTML attributes from the live properties Angular usually binds.

angular

Event binding runs a template statement when a DOM or component event occurs.

  • Parentheses name the event, as in (click)="save()".
  • The statement can call a component method or assign a value.
  • Data flows from the event source back into the component rather than from the component into the view.

Why interviewers ask this: This checks whether you understand how Angular templates respond to user and component events.

angular

$event is the event payload Angular passes to a template event handler.

  • For a native DOM event, it is the browser event object.
  • For a component output, it is the value emitted by that output.
  • The template can pass it to a typed component method for handling.

Why interviewers ask this: The interviewer evaluates whether you know how event data reaches component code.

angular

Two-way binding combines an input property binding with a matching change event binding.

  • The banana-in-a-box syntax [(...)] displays a value and writes changes back.
  • [(ngModel)] commonly synchronizes a form control with a component field.
  • It is convenient for editable values but still represents two one-way flows.

Why interviewers ask this: A good answer explains both directions instead of treating two-way binding as special hidden state.

templates

Using [(ngModel)] requires the NgModel directive provided by Angular's FormsModule.

  • An NgModule-based component imports FormsModule through its owning module.
  • A standalone component adds FormsModule to its own imports.
  • Inside a form, a bound control also needs a name so Angular can register it.

Why interviewers ask this: The interviewer checks whether you know the basic dependency behind Angular template-driven form binding.

They connect a template and component in different directions and for different targets.

  • Interpolation renders an expression as text.
  • Property binding sends a typed value from the component to a property.
  • Event binding sends notification data from the view or child component to a handler.

Why interviewers ask this: This tests whether you can choose the correct fundamental binding form by purpose.

*ngIf conditionally adds or removes a template block according to an expression.

  • A truthy condition creates the block and its Angular view.
  • A falsy condition removes that view rather than merely hiding its elements with CSS.
  • Modern Angular also offers built-in @if control flow, but *ngIf remains common in existing applications.

Why interviewers ask this: The interviewer checks whether you understand conditional rendering and the status of the legacy structural directive.

*ngIf can reference an ng-template as the block to render when its condition is false.

  • The then branch is the element carrying *ngIf unless another template is named.
  • The else option points to a template reference such as else emptyState.
  • ng-template itself does not create a visible wrapper element.

Why interviewers ask this: This checks basic knowledge of conditional branches and Angular template references.

*ngFor creates one embedded view for each item in an iterable collection.

  • The let syntax exposes the current item to the repeated template.
  • Local values such as index, first, and last describe each iteration.
  • Modern Angular also offers built-in @for control flow, while *ngFor is still widely found in Angular codebases.

Why interviewers ask this: The interviewer evaluates whether you understand Angular's traditional list rendering directive.

Stable item identity helps Angular reuse the correct DOM views when a collection changes.

  • Without custom tracking, *ngFor normally compares items by object identity.
  • A trackBy function can return a stable key such as a database ID.
  • Reusing views preserves element state and avoids unnecessary DOM recreation.

Why interviewers ask this: A strong junior answer connects list tracking with correct and efficient view reuse.

directives

Each structural directive shorthand expands into its own ng-template, so one host cannot represent two expansions at once.

  • The asterisk syntax is shorthand for wrapping content in an Angular template.
  • Nesting an ng-container provides a separate host for the second directive.
  • Separating the directives also makes their evaluation order explicit.

Why interviewers ask this: The interviewer checks whether you understand what the asterisk syntax represents.

angulardirectives

An attribute directive changes the appearance or behavior of an existing element, component, or directive.

  • It does not define a separate view like a component does.
  • It is applied through an attribute selector on its host.
  • NgClass and NgStyle are common built-in examples.

Why interviewers ask this: This tests whether you can distinguish behavior-focused directives from components and structural directives.

NgClass adds and removes CSS classes from an element based on a template expression.

  • It can accept a class string, an array of class names, or an object of class conditions.
  • Object keys are class names and truthy values enable those classes.
  • A direct [class.active] binding is often simpler for one conditional class.

Why interviewers ask this: The interviewer checks whether you know the standard Angular tool for dynamic class sets.

Locked questions

  • 21

    What does NgStyle do?

  • 22

    What are the basic parts of a custom attribute directive?

    directives
  • 23

    What is an Angular service?

    angular
  • 24

    What is dependency injection in Angular?

    angulardependency-injectioninjection
  • 25

    What is a provider in Angular dependency injection?

    angulardependency-injectioninjection
  • 26

    How can a class obtain a dependency in modern Angular?

    angulardependencies
  • 27

    What does providedIn: 'root' mean for an Angular service?

    angular
  • 28

    What is an NgModule?

    modules
  • 29

    What do declarations, imports, exports, providers, and bootstrap mean in an NgModule?

    modules
  • 30

    What is a standalone component in Angular?

    componentsangularstandalone-components
  • 31

    How does a standalone component make another component or directive available to its template?

    componentsdirectivesstandalone-components
  • 32

    Can standalone components and NgModules be used together?

    componentsmodulesstandalone-components
  • 33

    What are Angular lifecycle hooks?

    hooksangularlifecycle
  • 34

    When is ngOnInit called and what belongs there?

    lifecycle
  • 35

    When is ngOnChanges called?

  • 36

    What information does SimpleChanges provide to ngOnChanges?

  • 37

    When is ngOnDestroy called and what belongs there?

  • 38

    How does a component constructor differ from ngOnInit?

    componentslifecycle
  • 39

    What is an Angular pipe?

    angularpipes
  • 40

    Which built-in Angular pipes should a junior developer know?

    angular
  • 41

    What are the basic parts of a custom Angular pipe?

    angularpipes
  • 42

    How do pipe parameters and pipe chaining work?

    pipes
  • 43

    What is a template-driven form in Angular?

    formsangulartemplates
  • 44

    Why does an input using ngModel inside a form need a name?

    forms
  • 45

    What do valid, invalid, pristine, dirty, touched, and untouched mean in Angular forms?

    angular
  • 46

    How is basic validation declared in a template-driven Angular form?

    formsangulartemplates
  • 47

    What is Angular routing and how is a basic route defined?

    angular
  • 48

    What are RouterLink and RouterOutlet used for?

  • 49

    What does @Input do in an Angular component?

    componentsangular
  • 50

    What do @Output and EventEmitter do in an Angular component?

    componentsangular
  • 51

    How would you build a standalone product-list component that can be routed to directly?

    componentsstandalone-components
  • 52

    A loaded list is empty; how would you distinguish loading, error, empty, and populated UI states?

    state
  • 53

    How would you render selectable rows without putting row behavior in the page component?

    components
  • 54

    Input data is unavailable in the constructor; where should dependent initialization run?

  • 55

    A component adds a third-party event listener in ngOnInit; what cleanup does it need?

    componentslifecycledependencies
  • 56

    How would you reuse one status badge on several feature screens?

  • 57

    Template data is undefined until HTTP completes; how would you prevent runtime errors?

    templateshttpfundamentals
  • 58

    A bound value changed in ngAfterViewInit and caused ExpressionChangedAfterItHasBeenCheckedError; how would you fix it?

  • 59

    How would you build a typed login form with FormBuilder?

    forms
  • 60

    When should a reactive form show a required-field error?

    reactforms
  • 61

    You load a partial profile into a FormGroup; would you use setValue or patchValue?

    forms
  • 62

    How would you let users add and remove phone numbers in a form?

    forms
  • 63

    A city selector must reload when country changes; how would you wire it?

  • 64

    How would you prevent double submission while saving a form?

    forms
  • 65

    After a successful create request, how would you reset a form without losing defaults?

    forms
  • 66

    The server says an email is already used; how would you show it on the form?

    forms
  • 67

    The template cannot find a control named email; what would you inspect?

    templates
  • 68

    How would you validate that password and confirmation match?

    passwordsvalidation
  • 69

    A search form fires on every keystroke; how would you reduce requests?

    forms
  • 70

    A Save button remains enabled for an invalid form; how would you diagnose it?

    forms
  • 71

    How would you populate an edit form without a late response overwriting user edits?

    forms
  • 72

    How would you fetch a typed user list with HttpClient and expose it to a component?

    components
  • 73

    HttpClient injection fails in a standalone app; how would you fix it?

    standalone-componentsinjection
  • 74

    How would you send optional search and page values as query parameters?

    queries
  • 75

    How would you submit a typed create-user request and use the returned entity?

  • 76

    How would you keep loading correct when an HTTP request fails?

    http
  • 77

    Two searches run quickly and the older response arrives last; how would you fix it?

  • 78

    The same HttpClient GET runs twice because two places subscribe; how would you address it?

  • 79

    Where would you map an API user response into the smaller model needed by a component?

    componentsapi
  • 80

    How would you add an authorization header without repeating code in every service?

    auth
  • 81

    A details request returns 404; how would you handle it without returning an empty object?

  • 82

    How would you implement Retry after a failed list request?

    resilience
  • 83

    A parent passes a user to a child editor; how should the child avoid mutating it before Save?

  • 84

    How would a child notify its parent that a row was deleted?

  • 85

    A child emits an event but the parent handler never runs; what would you check?

  • 86

    Two siblings need the selected customer; how would you connect them?

  • 87

    How would a shared service deliver the latest selected item to late subscribers?

  • 88

    A service subscription updates a field in an OnPush component, but the view stays stale; how would you fix it?

    components
  • 89

    How would you configure routes for a product list and required product identifier?

    config
  • 90

    When would you use routerLink instead of Router.navigate?

  • 91

    A details component stays mounted from /products/1 to /products/2; how should it reload?

    components
  • 92

    How would you keep a list's page and filter in query parameters?

    queries
  • 93

    How would you add a not-found page for unknown routes?

  • 94

    How would you implement a basic guard for a login-required page?

    routing
  • 95

    A route parameter is missing or non-numeric; how would you avoid a bad API request?

    api
  • 96

    A component manually subscribes to a long-lived stream and leaks after navigation; how would you fix it?

    components
  • 97

    You need a view model from current-user and selected-project streams; how would you combine them?

  • 98

    Where would you use map, tap, catchError, and finalize in one loading stream?

  • 99

    One subscribe is nested inside another to load an order after customer changes; how would you rewrite it?

  • 100

    An OnPush child gets new async-pipe values but a mutated input stays stale; what would you change?

    pipesasync