AngularJS developer interview questions for legacy and migration roles
AngularJS developer interview questions are about keeping an older 1.x application healthy and getting it ready to move: scopes and the digest cycle, directives and isolate bindings, services and minification-safe dependency injection, and the plan for migrating to modern Angular or another framework. Expect to read and debug real legacy code more than to build something new. Strong candidates explain why the old framework behaves the way it does and how they would change it without breaking production.
By Evin JohnPublished 9 min read
What an AngularJS developer job usually is
AngularJS is the original 1.x framework. Google ended its long-term support at the end of 2021, so new projects rarely start on it, but many internal tools, banking portals, admin panels and healthcare systems still run on it. A posting with this title tends to want one of three things: someone to keep a large legacy app stable and secure, someone to lead its migration, or both at once. Some recruiters also write "AngularJS" when they mean modern Angular. Ask in the first call, because the questions are very different. If it turns out to be the newer framework, use the Angular interview guide instead.
- Reading old code fast: controllers with hundreds of lines, nested scopes, jQuery mixed in, and directives nobody remembers writing.
- Safe change: adding features and fixing bugs without a full rewrite and often with thin test coverage.
- Migration judgment: knowing what to move first, what to leave, and how to keep two frameworks running side by side.
- Risk awareness: an unsupported framework means dependency, browser and security questions that the team must answer on purpose.
How the interview is usually run
- Recruiter screenWhich AngularJS versions you used, app size, whether you have done a migration, and how much modern framework experience you have.
- Technical conversationScopes, the digest cycle, directives, services and routing. Interviewers often ask you to explain a behavior rather than define a term.
- Code reading or debuggingA snippet where the view does not update, a watcher fires forever, or a minified build breaks. You talk through the cause and the fix.
- Take-home or pairing taskAdd a small feature to a legacy-style app or convert a directive into a component. Some teams ask you to write a short migration note.
- Team and behavioral roundWorking in code you did not write, convincing a team to invest in migration, and handling a production bug in an old system.
Scopes and the digest cycle
| Question | What it tests | What a strong answer shows |
|---|---|---|
| Walk me through what happens when a user types into an input bound with ng-model. | The update path | The input event runs inside Angular's handler, the model is set, a digest walks the watchers, and changed watchers update the view |
| Why does a value set inside a setTimeout or a third-party callback not show on screen? | Code outside Angular | Nothing triggered a digest; use $timeout or wrap the change in $apply, and know that $apply runs a digest from the root scope |
| What does the error about ten digest iterations mean? | Unstable watchers | Watchers keep changing values that other watchers read, so the loop never settles; often a watch expression that returns a new object or array each time |
| How does prototypal scope inheritance cause the "dot rule" bug? | Scope model | A child scope (ng-if, ng-repeat) writing to a primitive creates its own copy; binding to a property of an object, or using controller-as, avoids it |
| What is the difference between $watch, $watchGroup and $watchCollection? | Watcher types | Reference watch by default, a deep watch with the third argument, a shallow collection watch for arrays, and the cost of each |
| When would you use $evalAsync or $applyAsync? | Scheduling | To queue work into the current or next digest instead of forcing a new one, and to batch many HTTP responses into one digest |
| How do you remove a watcher or listener you registered? | Cleanup | Keep the deregistration function that $watch and $on return, and call it, usually on the scope's $destroy event |
A clear way to explain dirty checking is to show it in a few lines. This toy is not AngularJS code, but it behaves the same way on the two points interviewers probe: nothing updates until a digest runs, and watchers that keep changing each other hit a limit.
function Scope() { this.watchers = []; }
Scope.prototype.watch = function (getValue, onChange) {
this.watchers.push({ getValue, onChange, last: undefined });
};
Scope.prototype.digest = function () {
let rounds = 0;
let dirty;
do {
dirty = false;
for (const w of this.watchers) {
const value = w.getValue(this);
if (value !== w.last) {
const old = w.last;
w.last = value;
w.onChange(value, old, this);
dirty = true; // a listener may have changed something, so check again
}
}
if (dirty && ++rounds >= 10) throw new Error("watchers never settled");
} while (dirty);
};
const scope = new Scope();
scope.firstName = "Ada";
scope.watch((s) => s.firstName, (v, old, s) => { s.greeting = "Hello, " + v; });
scope.watch((s) => s.greeting, (v) => console.log("view shows:", v));
scope.digest(); // view shows: Hello, Ada
scope.firstName = "Grace"; // changed outside the loop: nothing happens yet
scope.digest(); // view shows: Hello, GraceDirectives, components and bindings
- When would you write a directive instead of a component? Components (added in 1.5) suit UI pieces with their own template and bindings. Directives are still needed for attribute behavior on existing elements, DOM manipulation in link functions, or custom compile steps.
- Explain the isolate scope binding symbols.
=is two-way,<is one-way (1.5 and later),@passes a string or interpolated value, and&passes an expression the child can call, which is how child components send events up. - What is the difference between compile, pre-link and post-link? Compile runs once on the template before scopes exist; link functions run per instance with a scope. Post-link is where most DOM work goes because child elements are already linked.
- What is transclusion and when have you used it? It lets a directive wrap content the caller supplies, such as a panel or modal body, while that content keeps the outer scope.
- Which component lifecycle hooks exist?
$onInit,$onChanges,$doCheck,$onDestroyand$postLink. Moving setup into$onInitis one of the first steps when preparing code for migration. - Why use controller-as syntax? It makes the template show which controller a value comes from, avoids the dot-rule bug, and maps more cleanly to class-based components later.
Services, dependency injection and minification
| Question | What it tests | What a strong answer shows |
|---|---|---|
| What is the difference between a service, a factory and a provider? | Registration styles | All produce singletons; a factory returns a value, a service is instantiated with new, and a provider can be configured in a config block before the app runs |
| The app works in development but breaks after minification. Why? | DI annotation | Implicit injection reads parameter names, which minifiers rename; use the array syntax or $inject, or a build step that adds annotations |
| How would you share state between two controllers? | Design | A service holds the state and exposes methods; avoid $rootScope as a global store and avoid events for data that is really shared state |
| How do $http interceptors work, and what have you used them for? | Cross-cutting logic | A factory with request, response and error hooks registered on $httpProvider, used for auth headers, token refresh and central error handling |
| How does $q differ from native promises? | Async model | $q callbacks run inside a digest so the view updates; native promises resolve outside it, which is why mixing them can leave a stale view |
angular.module("billing").controller("InvoiceListController", InvoiceListController);
InvoiceListController.$inject = ["invoiceService", "$log"];
function InvoiceListController(invoiceService, $log) {
var vm = this;
vm.invoices = [];
vm.$onInit = function () {
invoiceService.list()
.then(function (rows) { vm.invoices = rows; })
.catch(function (err) { $log.error("could not load invoices", err); });
};
}Routing, forms and HTTP
- ngRoute or UI-Router, and why? ngRoute handles one view per route. UI-Router adds nested states and named views, which large apps usually need. Mention resolves that load data before a state is entered.
- How do you validate a form? Use the form controller's
$valid,$dirtyand$touchedflags, built-in validators, and custom validators throughngModel.$validatorsor$asyncValidatorsfor server checks. - How do you stop a search box from calling the server on every key?
ng-model-optionswith a debounce, plus cancelling the previous request with a timeout promise. - How do you handle an expired session in a legacy app? An interceptor catches the 401, refreshes once or sends the user to sign in, and queues requests made during the refresh.
Performance on large legacy screens
| Question | What it tests | What a strong answer shows |
|---|---|---|
| A table with a few thousand rows makes typing slow. What do you check first? | Watcher count | Count watchers, since each digest visits all of them; cut bindings, paginate or virtualize, and move static values to one-time bindings |
| What does the double-colon syntax do? | One-time binding | The binding stops watching once the value is defined, which removes many watchers from read-only views |
| Why add track by to ng-repeat? | DOM reuse | Without it, replacing the array rebuilds every row; tracking by a stable id lets Angular reuse rows |
| When is ng-if better than ng-show? | Hidden cost | ng-show keeps hidden elements and their watchers alive; ng-if removes them, at the cost of rebuilding when shown |
| What else can you switch off in production? | Build settings | Debug info on the compile provider, and the comment and class directive lookups if the app does not use them |
Testing code nobody tested
- How do you unit test a controller? Load the module with angular-mocks, create it with
$controllerand a fresh scope from$rootScope.$new(), and inject fakes for its services. - How do you test code that calls $http? Use
$httpBackendto declare expected requests and canned responses, then flush them so the test controls timing. - Where do you start when coverage is close to zero? Characterization tests around the behavior you are about to change, plus a few end-to-end checks on the main user paths, before refactoring anything.
Migration questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| Rewrite from scratch or migrate in place? | Judgment | Usually incremental: the app keeps shipping while screens move one by one; a rewrite only when the app is small or the old code is beyond repair |
| How does a hybrid app with ngUpgrade work? | Hybrid setup | Both frameworks boot together, old services and components are upgraded for use in new code and new components are downgraded for old templates, with routing split between them |
| What would you do before any new framework code is written? | Preparation | Move to components and controller-as, remove $scope soup and $rootScope events, add a module bundler and TypeScript, and add tests on the main flows |
| Which screen would you migrate first? | Sequencing | A self-contained screen with clear value and low risk, then shared services, leaving the most tangled screen until the team has practiced |
| How do you make the case for migration to the business? | Communication | Security and hiring risk of an unsupported framework, the cost of slow changes, and a staged plan with visible milestones rather than a long freeze |
| Some teams pay for extended support instead. When is that reasonable? | Options | When the app is near retirement or the migration is funded but years away; it buys time on security fixes, not on hiring or developer speed |
Fictional example
- I joined a team running an insurance quoting portal built on AngularJS 1.6, with about ninety screens and almost no tests. Leadership wanted a rewrite; I argued for a hybrid migration because the business could not freeze features for a year. We spent the first six weeks on preparation: we converted the most-used directives to components, removed events on $rootScope, and wrote browser tests for the five quote flows that produced most revenue. Then we booted modern Angular next to the old app with ngUpgrade and moved the policy summary screen first, since it had clear boundaries. One mistake: we upgraded a shared pricing service too early and spent two weeks chasing digest timing bugs between the two frameworks. After that, we moved shared services only once every screen using them had moved. By the time I left, about a third of the screens were on the new framework and releases had not slowed down.
Behavioral questions for legacy work
- Tell me about a bug in old code you did not write. Show how you narrowed it down, not only the fix.
- Describe a time you persuaded a team to pay down technical debt. Tie it to delivery speed or risk, with what changed afterward.
- How do you keep your skills current while working on an old stack? Real examples: side projects in a newer framework, or leading the migration work itself.
For the story structure, use the behavioral question guide. Teams migrating a legacy front end also redesign the APIs it calls, and broader questions on the language itself are in the JavaScript interview guide.
A one-week preparation plan
- Day 1: reread how scopes inherit, how a digest runs and how to debug the ten-iterations error.
- Day 2: write one directive with an isolate scope and transclusion, then rewrite it as a component.
- Day 3: practice minification-safe injection and an $http interceptor that adds a token and handles a 401.
- Day 4: profile a long ng-repeat, count watchers, and fix it with track by and one-time bindings.
- Day 5: write a one-page migration plan for an imaginary app: preparation steps, first screen, hybrid setup, risks.
- Days 6 to 7: prepare three stories: a legacy bug, a debt conversation and a change you shipped safely without tests.
Explaining dirty checking out loud is harder than reading about it. Natively, an AI interview assistant for Mac and Windows, can transcribe a practice session on your computer so you can check whether your explanation of a digest actually followed the order of events. During mock questions it can suggest a response to the question just asked, read a legacy snippet from a screenshot and offer an approach, and with your résumé and the job description added (Pro or the free trial) tie suggestions to the systems you have maintained. The transcript and notes are kept for review.
Questions people ask
What questions are asked in an AngularJS developer interview?
Expect questions on scope inheritance and the digest cycle, $apply and $timeout, directives and isolate bindings, services and minification-safe injection, ng-repeat performance, testing with angular-mocks, and how you would migrate the app.
Is AngularJS the same as Angular?
No. AngularJS is the 1.x framework and modern Angular is a separate rewrite with different concepts. Some job posts mix the names, so ask which one the team uses before you prepare.
Is it worth taking an AngularJS job today?
It can be, especially if the role includes the migration. You learn legacy debugging and staged migration, which transfer well. Ask how much of the work is maintenance and whether a move off 1.x is funded.
How do I prepare for an AngularJS interview quickly?
Review the digest cycle and scope inheritance, write a directive and convert it to a component, practice an $http interceptor, fix a slow ng-repeat, and write a short migration plan you can talk through.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
