Angular components combine the user interface, behavior, and styles into one reusable piece. This makes them like building blocks that you can assemble to create complex apps.
ParentComponent and ChildComponent. If ChildComponent is used inside ParentComponent's template, what is the result?<!-- ParentComponent template --> <app-child></app-child>
Nesting components means the child component's UI and behavior appear inside the parent component's view, allowing modular and organized UI building.
ngOnInit method is part of the component lifecycle. When exactly is it called?ngOnInit runs once after Angular sets up the component's input properties, making it the right place for initialization logic.
import { Component, signal } from '@angular/core'; @Component({ selector: 'app-counter', standalone: true, template: ` <p>Count: {{ count() }}</p> <button (click)="increment()">Increment</button> ` }) export class CounterComponent { count = signal(0); increment() { this.count.update(c => c + 1); } }
The count signal starts at 0 and increments by 1 each click. After two clicks, it becomes 2.
Option A correctly sets standalone: true and includes a template, which is required for standalone components in Angular 17+.
