To design and create an Angular component, you write a TypeScript class decorated with @Component, attach an HTML template and optional styles, and register the component with a module or import it directly into a standalone component; to update one, you change its class properties and template bindings so that Angular's change detection re-renders the view, using @Input for data flowing in, @Output for events flowing out, and lifecycle hooks when you need work to happen at a specific point. The rest of this article explains what each of those pieces does, how the pieces fit together, and where the common points of confusion sit — especially the difference between updating component data and updating the component's code or dependency version.

What a component actually is

An Angular component is the smallest unit of user interface the framework knows about. It consists of three things that work together:

A class that holds state and behavior — properties like title or count, and methods like increment(). A template — HTML that describes the view and binds to the class's properties and methods. Metadata — the @Component decorator, which tells Angular which selector to use, where the template lives, and where styles live.

This trio is why Angular components feel heavier than plain HTML custom elements: the class, template, and styles are compiled together so that bindings stay synchronized. When a property changes, Angular re-evaluates the template expressions that reference it and updates the DOM where needed. You do not manually manipulate the DOM for ordinary state changes; you change the data and let the framework render the result.

Designing a component before writing code

Design decisions made in the first few minutes determine how painful the component is to reuse. The key ones:

Scope and responsibility. A component should do one identifiable thing. If you find yourself adding unrelated state and controls to the same class, split it. A "user card" and a "user list" are separate components even when the list only ever shows cards.

Inputs and outputs. Decide what the component receives from its parent (@Input) and what it emits back (@Output). A component that reaches into a shared service for everything is harder to reuse than one whose data arrives through inputs.

State ownership. Ask which component owns each piece of state. If only one parent needs the value, keep it in the parent and pass it down. Sharing through a service is appropriate when siblings or distant components must stay in sync.

Presentation vs. container. A useful convention is to separate "container" components that fetch and coordinate data from "presentational" components that only render inputs and emit events. This is a convention, not a framework rule, but it makes testing and reuse much easier.

Change detection strategy. Most components can use the default strategy. If a component is expensive to render and its inputs change infrequently, ChangeDetectionStrategy.OnPush can reduce checks — but only if you are disciplined about immutable inputs and explicit change triggers. Adopting OnPush without understanding it is a common source of "the view won't update" bugs.

Creating a component: the practical steps

Option 1: The Angular CLI

The standard way to create a component is the CLI:

(Shorthand: ng g c user-card.) The CLI creates a folder with four files — the TypeScript class, an HTML template, a stylesheet, and a test file — and, in a classic NgModule-based project, adds the component to the nearest module's declarations. In a standalone project, the generated component imports its own dependencies and does not need a module.

The CLI is worth using not because typing files by hand is hard, but because it keeps naming consistent, wires up registration correctly, and respects the project's configured style. The name you give the CLI also determines the selector: user-card produces a selector of app-user-card by default, following the project's prefix.

Option 2: By hand

Creating a component manually is entirely legitimate and clarifies what the CLI automates. A standalone component looks like this:

If you are working in an NgModule-based project rather than a standalone one, you omit standalone: true, use templateUrl and styleUrl/styleUrls to point at separate files, and add the class to a module's declarations array. Mixing the two approaches — a standalone component that you also declare in a module — causes confusing errors, so pick one model per project unless you have a deliberate migration reason.

Registering and using the component

A standalone component must be imported by whatever uses it: a parent standalone component's imports array, or an NgModule's imports array. Then you use it through its selector:

The square brackets are property bindings (data flows in); the parentheses are event bindings (data flows out). Getting these two syntaxes straight resolves a large share of beginner confusion, because they are the whole mechanism of parent-child communication.

How updating works: data changes

"Update a component" most often means "change what the component displays when the underlying data changes." This happens through Angular's change detection: when events, timers, HTTP responses, or other asynchronous work complete, Angular checks components and re-renders bindings whose values have changed.

The practical rules:

Mutate through bindings, not DOM manipulation. Set this.count = this.count + 1 in the class and let {{ count }} update. Calling document.querySelector to change text defeats the framework and breaks tests and server-side rendering.

Replace rather than mutate when using OnPush. With the default strategy, mutating an array (items.push(x)) is generally picked up. With OnPush, the component is only checked when its inputs change by reference or when an event occurs inside it, so mutating an input object may not refresh the view. Creating a new array (items = [...items, x]) sends a new reference and triggers the update. This distinction explains the frustrating "my list updates in one component but not another" scenario.

Watch out for reference types in inputs. Passing an object into a child and mutating its properties will not trigger OnPush change detection on the child, even though the child still sees the new property values the next time it is checked. Decide early whether inputs are immutable snapshots or shared mutable state.

Use lifecycle hooks for timing, not for manual syncing. ngOnInit runs once after the first input binding is set — the right place for setup that depends on inputs. ngOnChanges fires whenever an input reference changes — useful for reacting to specific input updates. ngOnDestroy is for cleanup: unsubscribing, clearing timers, detaching listeners. Avoid writing change detection logic inside these hooks; if you feel the need, you probably have a data-flow problem.

Signals change the mechanics, not the concept. Newer Angular versions offer signal-based inputs and reactive state (signal, computed). A signal read in the template is tracked directly, so updating it (count.set(count() + 1)) notifies Angular precisely. The design principles above still apply; signals simply make the dependency tracking explicit and often let OnPush behave more predictably.

Updating the component's own code and dependencies

The other common meaning of "update component" is updating the code itself — upgrading Angular, replacing a deprecated API, or refactoring a template. Those are ordinary software maintenance tasks rather than runtime behavior. The important boundary is version-dependent: decorator options, standalone defaults, and the availability of signals have changed across major Angular releases, and APIs deprecated in one major version may be removed in the next. Consult the official Angular update guide for the specific versions involved rather than assuming syntax you saw in an older tutorial still applies.

A worked example: search box with live results

A small example ties the concepts together. A SearchBoxComponent owns the input text, and its parent receives emitted queries:

Design decisions made here: the component owns only the query string; the parent owns the actual searching and result list. The component emits every keystroke and lets the parent debounce, cache, or cancel requests. This keeps the search box reusable and the parent in control of policy. Note the [value]="query" binding — a controlled input pattern that ensures the displayed text follows the class property rather than drifting out of sync.

The parent then updates its own state in the handler:

When results arrive asynchronously, assigning this.results = data updates the template; there is no manual DOM step.

Common mistakes and how to avoid them

Forgetting to import a standalone component into the consuming component or module. The symptom is a template error saying the element is not a known element. The fix is an import, not a declaration. Declaring a standalone component in an NgModule. Pick standalone or NgModule registration; do not do both. Overusing services for parent-child data flow. Inputs and outputs exist precisely so children remain decoupled from where their data comes from. Manual DOM access for ordinary rendering. It breaks on server rendering, complicates tests, and bypasses change detection. Toggling OnPush to fix a bug. If the view stops updating after switching to OnPush, the cause is usually a mutated input reference. Fix the data flow rather than reverting the strategy unthinkingly. Putting business logic in templates. Templates should bind, loop, and branch; calculations belong in the class or in computed values, where they can be tested.

What "update" is not asking you to do

Angular's change detection is automatic for ordinary state changes, so you rarely need to write code whose job is "make the view update." The framework checks bindings after asynchronous work and events. If you find yourself reaching for manual change-detection triggers, treat that as a signal that something upstream — usually state mutation that change detection cannot see, or an improper OnPush setup — needs fixing instead.

One genuine exception is integrating non-Angular code, such as a third-party widget that updates or a callback fired outside Angular's awareness. In those cases you may need to bring the callback back into Angular's context (for example, with NgZone.run or by converting the callback into a signal). This is an integration concern, not the normal way to update a component.

Quick reference: creation vs. updating

Task What you do What Angular does
Create a component @Component class with selector, template, styles; import or declare it Compiles it and wires bindings
Pass data down @Input property, bound with [prop]="value" Snapshot or reference-check the input
Send events up @Output with EventEmitter, bound with (event)="handler()" Calls the handler; checks the parent after
Update displayed data Change class properties (or signals) Re-renders affected bindings
Run setup or cleanup ngOnInit, ngOnChanges, ngOnDestroy Invokes hooks at defined points
Update the code/version Follow the official upgrade guide for your versions —

The through-line is that a component is a class plus a template, and updates are data changes that the framework propagates. Design the inputs and outputs deliberately, let bindings carry the data, keep state ownership clear, and use OnPush and signals only with a deliberate plan — and both creating and updating components in Angular become straightforward, predictable work.