Complete the code to create a standalone Angular component.
import { Component } from '@angular/core'; @Component({ selector: 'app-hello', template: `<h1>Hello Angular!</h1>`, [1]: true }) export class HelloComponent {}
The standalone property makes the component standalone, which is recommended in Angular 17+ for enterprise apps.
Complete the code to inject a service using Angular's new inject() function.
import { Component, inject } from '@angular/core'; import { DataService } from './data.service'; @Component({ selector: 'app-data', template: `<p>Data loaded</p>`, standalone: true }) export class DataComponent { dataService = [1](DataService); }
The inject() function is the modern way to get services in Angular 17+ standalone components.
Fix the error in the Angular template syntax for conditional rendering.
<div *[1]="showContent"> <p>Content is visible</p> </div>
The correct Angular directive for conditional rendering is *ngIf.
Fill both blanks to create a reactive signal and update it on button click.
import { Component, signal } from '@angular/core'; @Component({ selector: 'app-counter', template: ` <p>Count: {{ count() }}</p> <button (click)="[1]()">Increment</button> `, standalone: true }) export class CounterComponent { count = signal(0); [2]() { this.count.update(c => c + 1); } }
The method to update the signal is named incrementCount, and the button calls increment() which should match the method name. Here, the button calls increment() but the method is incrementCount(), so the blanks fix this mismatch.
Fill all three blanks to create a standalone Angular component with a signal and a button to reset it.
import { Component, signal } from '@angular/core'; @Component({ selector: 'app-reset', template: ` <p>Value: {{ [1]() }}</p> <button (click)="[2]()">Reset</button> `, [3]: true }) export class ResetComponent { value = signal(100); reset() { this.value.set(0); } }
The template uses the signal value to display, calls the reset method on button click, and the component is marked as standalone.