Documentation Index
Fetch the complete documentation index at: https://resources.devweekends.com/llms.txt
Use this file to discover all available pages before exploring further.
Module Overview
Estimated Time: 2-3 hours | Difficulty: Beginner | Prerequisites: HTML, CSS, JavaScript basics
- What Angular is and why it’s powerful
- Setting up your development environment
- Creating projects with Angular CLI
- Understanding the project structure
- TypeScript essentials for Angular
- How Angular applications bootstrap
What is Angular?
Angular is a platform and framework for building single-page client applications using HTML and TypeScript. Developed and maintained by Google, it is one of the most widely adopted frameworks for enterprise web development — companies like Google (Google Cloud Console, Firebase Console), Microsoft (Office 365, Xbox), Deutsche Bank, and Forbes all run Angular in production. Angular provides:Complete Solution
Routing, forms, HTTP, testing—everything included out of the box
TypeScript First
Built with TypeScript for better tooling and maintainability
Component-Based
Build UIs from reusable, self-contained components
Enterprise Ready
Scalable architecture for large applications
Angular vs React vs Vue
| Feature | Angular | React | Vue |
|---|---|---|---|
| Type | Full Framework | Library | Progressive Framework |
| Language | TypeScript | JavaScript/TypeScript | JavaScript/TypeScript |
| Architecture | Opinionated | Flexible | Flexible |
| Learning Curve | Steeper | Moderate | Gentle |
| Best For | Enterprise Apps | Flexible Projects | Progressive Adoption |
| Maintained By | Meta | Community |
Setting Up Your Environment
Prerequisites
- Node.js (version 18.x or higher)
- npm (comes with Node.js)
- Code Editor (VS Code recommended)
Installing Angular CLI
The Angular CLI (Command Line Interface) is the official tool for creating, developing, and maintaining Angular applications. Think of it like a Swiss Army knife for Angular development — it scaffolds projects, generates components, runs tests, builds for production, and handles configuration so you can focus on writing features instead of wrestling with tooling.Pro Tip: If you encounter permission errors on macOS/Linux, consider using
nvm (Node Version Manager) or prefix with sudo.VS Code Extensions
Install these extensions for the best Angular development experience:Creating Your First Angular App
Generate a New Project
- Would you like to add Angular routing? → Yes
- Which stylesheet format? → CSS, SCSS, Sass, or Less
Recommendation: Choose SCSS for more powerful styling capabilities with variables, nesting, and mixins.
Project Structure
Understanding Key Files
main.ts - Application Entry Point
This is the first file that runs when your application starts. It is the equivalent of main() in Java or C — the single entry point that kicks everything off.
app.config.ts - Application Configuration
This is where you register application-wide services and features. Think of it as the “settings panel” for your entire app — routing, HTTP, animations, and any global services all get configured here.
app.component.ts - Root Component
TypeScript Essentials for Angular
Angular is built with TypeScript. Here are the key concepts you need:Type Annotations
Classes and Decorators
If you are coming from React or Vue, decorators might be new to you. A decorator is a special annotation (the@ symbol) that attaches metadata to a class, property, or method. Angular reads this metadata at runtime to understand what a class is supposed to do. Think of decorators like name badges at a conference — the badge does not change who you are, but it tells the framework how to treat you.
Generics
Angular CLI Commands
The CLI provides many useful commands:Component Generation Options
How Angular Apps Bootstrap
Understanding the bootstrap process helps you debug issues and configure your app correctly. When something goes wrong at startup — a blank screen, a “missing provider” error, or a component that does not render — knowing this sequence tells you exactly where to look.Practical tip: If you see a blank page with no errors in the console, the issue is almost always in step 3-6. Check that your
AppComponent selector matches the tag in index.html, and that appConfig has all required providers.index.html
Your First Component
Let’s create a simple component to understand the basics:Component Code
Using the Component
Angular DevTools
Install the Angular DevTools browser extension for debugging:- Install from Chrome Web Store or Firefox Add-ons
- Open Chrome DevTools (F12)
- Look for the “Angular” tab
Tip: Angular DevTools only works with development builds. Production builds have debugging disabled.
DevTools Features
- Component Explorer: Inspect component tree and properties
- Profiler: Analyze change detection performance
- Router: Debug routing state
Practice Exercise
Exercise: Create a Counter App
Create a simple counter application with:
- A display showing the current count
- Increment button (+)
- Decrement button (-)
- Reset button
Solution
Solution
Summary
In this module, you learned:Interview Deep-Dive
Q: Explain the role of Zone.js in Angular's bootstrap process. What would happen if you removed it, and how does Angular handle that scenario today?
Q: Explain the role of Zone.js in Angular's bootstrap process. What would happen if you removed it, and how does Angular handle that scenario today?
Strong Answer: Zone.js monkey-patches every asynchronous browser API — setTimeout, setInterval, Promise.then, addEventListener, XMLHttpRequest, fetch — and wraps them in “zones.” When any async operation completes inside Angular’s zone, Zone.js notifies Angular’s change detection to run a check from the root component down. This is why Angular “magically” updates the view when an HTTP response arrives or a timeout fires — Zone.js is the mechanism that triggers the check.If you removed Zone.js, Angular would have no way to know when async operations complete, so templates would never update automatically. You would need to manually call ChangeDetectorRef.detectChanges() or markForCheck() after every async operation. Starting with Angular 18, provideExperimentalZonelessChangeDetection() enables exactly this scenario — but it requires you to use signals for all template-bound state, because signals have their own notification mechanism that does not depend on Zone.js. The benefit is roughly 15KB less bundle size and no unexpected change detection triggered by third-party libraries.Follow-up: Can you describe a scenario where Zone.js causes a performance problem?
Answer: A common one is third-party charting libraries like D3 or Chart.js. These libraries use requestAnimationFrame and mousemove handlers internally, which Zone.js intercepts and triggers change detection on. If you have a chart with 60fps animations, Angular runs change detection 60 times per second across your entire component tree — even though none of your Angular data changed. The fix is to run the chart initialization inside NgZone.runOutsideAngular(), which tells Zone.js to ignore async operations in that callback.
Q: A junior developer on your team puts all their logic in ngOnInit and never uses the constructor. Is that a problem? When would you use one versus the other?
Q: A junior developer on your team puts all their logic in ngOnInit and never uses the constructor. Is that a problem? When would you use one versus the other?
Strong Answer: The constructor runs during class instantiation, before Angular has set any inputs or rendered any template. It is the right place for pure dependency injection setup — assigning injected services to class properties (though inject() now handles this declaratively). The constructor should never access @Input values because they have not been set yet.ngOnInit runs after Angular has set the initial input bindings and the component is fully wired up. This is the right place for initialization logic that depends on input values — fetching data based on a route parameter, setting up subscriptions that read from inputs, or any logic that needs the component to be “ready.”The common mistake is calling inject() in ngOnInit — that actually fails because inject() only works during the injection context (constructor or field initializer). So the practical rule is: use inject() for DI in field declarations, use ngOnInit for initialization logic that depends on inputs. Putting everything in ngOnInit is not technically wrong, but putting DI-dependent setup logic in the constructor is — because the component is not fully initialized yet.Follow-up: What about the new signal-based inputs? Does this change the ngOnInit pattern?
Answer: With signal inputs (input.required, input()), the value is available as a signal immediately, but it might not have its “real” value until after the parent sets it. You can use computed() and effect() to react to input changes reactively, which often eliminates the need for ngOnInit entirely. An effect that reads input signals will automatically re-run when the parent changes the input — no lifecycle hook needed.
Q: You are debugging a blank page in a new Angular app -- no errors in the console, just a white screen. Walk me through your debugging approach.
Q: You are debugging a blank page in a new Angular app -- no errors in the console, just a white screen. Walk me through your debugging approach.
Strong Answer: A blank page with no errors is almost always a bootstrap or selector mismatch issue. My debugging sequence: First, I check index.html to confirm the app-root tag is present and matches the selector in AppComponent. If the selector is app-root but index.html has app-component, nothing renders and there is no error. Second, I check main.ts to ensure bootstrapApplication is called with the correct component and config. Third, I check app.config.ts to make sure provideRouter(routes) is included if I expect routing. Fourth, I open the browser’s Network tab to verify JavaScript files loaded successfully — a 404 on main.js would cause a blank screen. Fifth, I check the Angular tab in DevTools (if the extension is installed) to see if the component tree exists at all.If all of that looks fine, the issue might be that routes are defined but the root template is missing a router-outlet, or the default route redirects to a path that does not match any route definition (a missing pathMatch: ‘full’ on the redirect is a classic culprit).Follow-up: How would your approach differ if there WERE errors in the console?
Answer: Then I read the error. The most common ones: “NullInjectorError: No provider for X” means a service is not providedIn root and was not added to providers. “NG0300: Multiple components match node with tagname X” means duplicate component selectors. “NG0100: Expression has changed after it was checked” means a value changes during change detection, usually from a getter or method call in the template that returns different values on consecutive reads.
Next Steps
Next: Components Deep Dive
Learn about component architecture, data binding, and communication patterns