Debug a running application
Read and change scopes, controllers, and services from browser DevTools
Use the cookbook when you have a concrete problem and need a working pattern. Start with debugging if AngularTS is new to you. Every progressive recipe ends with a task to apply and checks that prove it worked.
Start with beginner recipes, then choose forms, HTTP, DOM updates, security, performance, data correctness, navigation, operations, or advanced browser work.
Start from the result your application needs, not from a directive name.
| Needed result | Start with |
|---|---|
| The server already knows the final HTML | Swap server-rendered HTML |
| One interaction needs JSON and local template state | Build and submit forms |
| Several features share records and write operations | Read, write, and prefetch REST data |
| The browser must own URLs, history, and nested views | Add browser-owned routes |
| The server pushes one-way updates | Receive live server events |
| The browser and server both send live messages | Exchange WebSocket messages |
| Existing computation blocks rendering after measurement | Move measured CPU work to a worker |
| The measured runtime contains unused features | Build a smaller production runtime |
Prefer the first applicable row. Do not introduce a client route or shared data service when one server response and one declarative interaction solve the problem.
Data correctness: handle uniqueness races, submit money safely, send dates with zones, and keep identifiers opaque.
HTTP behavior: revalidate with ETag, serve maintenance responses, validate return redirects, standardize errors, and negotiate page or fragment.
Browser and content security: sanitize rich text, deploy CSP, harden session cookies, support password managers, and redact secrets.
Interaction details: focus the first error, design an empty state, and preserve focus after swaps.
Transaction workflows: respect rate limits, run background jobs, make critical writes idempotent, save multi-step forms, and apply bulk actions.
Account and record workflows: archive and restore, handle permission rejection, keep filters in the URL, and log out safely.
Production form workflows: show server validation, send CSRF proof, confirm deletion, and resolve concurrent edits.
Production response workflows: retry a failed read, paginate on the server, download with the browser, and swap trusted server HTML.
Keep important forms usable with progressive enhancement, and define their HTTP response contracts before wiring the success and failure branches.
| Problem | Recipe |
|---|---|
| Edit one record without leaving the page | Edit a server record in place |
| Delete one row without rebuilding its list | Delete a row after server confirmation |
| Search without stale responses winning | Search while the user types |
| Load choices from another field | Load one select from another |
| Show a reversible change immediately | Update immediately and roll back |
| Upload a file and allow cancellation | Cancel a file upload |
| Choose status, content type, and body | Design an HTTP response |
| Problem | Recipe |
|---|---|
| Data should be ready before click | Prefetch data before the user clicks |
| More rows should load near the viewport | Load the next page near the viewport |
| Stable lookup lists repeat | Cache reference data safely |
| A private request finds an expired session | Return users to login |
| A dialog needs current server content | Load a dialog from the server |
Start with the integration decision guide, then use
the event bus for transient messages,
ng-observe for reflected web-component attributes, or a
shared application model for current reactive state.
Production change management: deliver server flags, record audit events, and roll contracts out compatibly.
When an API must use another origin, follow the cross-origin request recipe before adding browser workarounds.
Make failures traceable with a request ID, then run the shipping check against the complete interaction.
Trace one interaction with the HTTP debugging recipe, then control repeated requests only after measuring them. Before shipping, audit the full server-driven interaction.
| Problem | Recipe |
|---|---|
| A server page needs one interactive widget | Add behavior without making an SPA |
| A component changed state but DOM did not | Make a component view reactive |
| Refreshed rows lose focus | Keep repeated rows stable |
| Hidden UI keeps doing work | Stop hidden UI work |
| An older request wins | Ignore stale request results |
| A listener survives its UI | Clean up browser resources |
| An interaction feels slow | Find the slow part |
| Request states are incomplete | Render every request state |
Read and change scopes, controllers, and services from browser DevTools
Let AngularTS place a native DOM element on a scope or controller
Initialize scope state once or keep it synchronized with server-rendered content
Let bindings update existing DOM when scope state changes
Add, remove, or switch DOM subtrees with structural directives
Select a target and insert, replace, append, or remove server HTML
Use scope watches for work outside AngularTS bindings
Respond to browser events and communicate through the scope tree
Bind fields, show useful errors, and submit valid data
Define a typed endpoint once and use it for CRUD operations
Configure cookie or bearer credentials once for framework services
Add cache-first, network-first, or stale-while-revalidate behavior
Register states, render them in ng-view, and protect private pages
Delay below-the-fold work with ng-viewport
Update scope or append HTML through Server-Sent Events
Run JavaScript in a Web Worker with ng-worker
Expose WebAssembly exports to scope with ng-wasm
Load an editor, submit JSON, and keep server validation beside the field
Let the server authorize deletion and remove only the successful row
Debounce requests and ignore responses for an older query
Request valid choices when a parent selection changes
Append server-rendered rows and replace the paging marker
Show a local change first while preserving the previous server value
Route a failed private request and preserve the intended destination
Cache stable lookup lists and invalidate them deliberately
Send FormData, abort through timeout, and distinguish cancellation
Swap server-rendered dialog content and restore focus on close
Compare the server-first approaches without assuming compatibility
Choose status, content type, and body before writing the directive
Preserve keyboard behavior, announce loading, and move focus deliberately
Check authorization, CSRF, HTML trust, caching, uploads, and errors
Build a normal server form first, then add faster in-page behavior
Trace an element, its scope, its request, and the resulting UI state
Measure duplicate work, then delay, throttle, cache, or cancel it
Keep validation authoritative on the server and render field errors in place
Send a server-issued proof with every state-changing form request
Require an explicit second action before sending a delete request
Detect stale updates and let the user compare the current server value
Keep the last useful state and retry only when the user asks
Keep URLs shareable while replacing only the result region
Use normal navigation for files instead of loading bytes into application state
Keep rendering on the server without compiling untrusted markup
Give users and operators one safe identifier for tracing a failure
Walk one feature through behavior, failure, access, and operations
Respect 429 responses without hiding retries or multiplying traffic
Start work quickly, expose status, and download the finished result
Prevent double charges, sends, and submissions with an idempotency key
Save each step independently instead of keeping a fragile browser-only draft
Submit explicit selections and return a result for every record
Make a destructive-looking action recoverable when the domain allows it
Let the server decide access and give the user a useful next step
Make filtered results reloadable, shareable, and usable without JavaScript
End the server session, clear private state, and avoid logout links
Configure CORS and credentials deliberately for a separate API origin
Let the database decide uniqueness and return the conflict to the field
Send a decimal string and perform currency arithmetic on the server
Distinguish calendar dates, local times, and exact instants
Avoid rounding, parsing, and leaking meaning through record IDs
Return 304 when unchanged instead of transferring the same representation
Return a clear 503 response while preserving public navigation and recovery
Preserve a destination without creating an open redirect
Make expected failures predictable without hiding their HTTP meaning
Let one server route return the representation the request actually needs
Sanitize stored markup and keep it separate from application templates
Measure executable-content dependencies before enforcing a restrictive policy
Keep session credentials out of JavaScript and restrict browser delivery
Use normal controls and autocomplete values before adding custom behavior
Return safe diagnostics while preserving enough context to trace failures
Move keyboard users directly to a field-level validation problem
Distinguish no data from loading and failure, then explain what to do
Keep the trigger stable or move focus to a deliberate result heading
Avoid a second request and keep authorization separate from rollout
Write an audit event in the same server operation as the state change
Expand, migrate, and contract server behavior across cached browser versions
Start with inspection, server data, DOM wiring, events, forms, and HTTP
Solve validation, uploads, conflicts, multi-step flows, and sensitive input
Choose statuses, bodies, caching, retries, fragments, and origin policy
Select, update, replace, animate, and focus application-owned elements
Protect requests, sessions, redirects, content, credentials, and permissions
Reduce requests, rendering, transfer, and main-thread work after measuring
Preserve identity, precision, concurrency, validation, and audit history
Keep URLs, server pages, router states, sessions, and redirects coherent
Trace failures, survive outages, control rollout, and explain sensitive changes
Use effects, viewport events, streams, workers, WebAssembly, and specialized UI
Build a bidirectional chat channel with reconnect and cleanup
Choose DOM ownership, messages, observed attributes, or shared reactive state
Use the application event bus for asynchronous cross-boundary notifications
Mirror reflected web-component attributes into AngularTS scope
Give AngularTS and another framework one reactive domain object
Compose, bundle, measure, and verify only the AngularTS features an application uses
Enhance one part of a page without building an SPA
Fix state changes that do not update a typed component view
Preserve row DOM when refreshed data represents the same records
Choose between removing UI and only hiding it
Keep older responses from replacing newer search results
Stop listeners, observers, and timers when a view is removed
Measure whether delay comes from JavaScript, layout, rendering, or the network
Show loading, success, empty, and error states without contradictory UI
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.