Complete the code to declare a presentational component with standalone setup.
import { Component } from '@angular/core'; @Component({ selector: 'app-presentational', template: `<p>Display data here</p>`, standalone: [1] }) export class PresentationalComponent {}
The standalone property must be set to true to make the component standalone.
Complete the code to inject a service into a container component using Angular's inject() function.
import { Component, inject } from '@angular/core'; import { DataService } from './data.service'; @Component({ selector: 'app-container', template: `<app-presentational [data]="data"></app-presentational>`, standalone: true, imports: [] }) export class ContainerComponent { private dataService = [1](DataService); data = this.dataService.getData(); }
Angular 17+ uses the inject() function to get service instances inside components.
Fix the error in the presentational component input binding syntax.
import { Component, Input } from '@angular/core'; @Component({ selector: 'app-presentational', template: `<p>{{ data }}</p>`, standalone: true }) export class PresentationalComponent { @Input() [1]: string = ''; }
The input property name must match the binding name used in the container component, which is data.
Fill both blanks to correctly pass data from container to presentational component.
<app-presentational [1]="[2]"></app-presentational>
Use property binding syntax [data] to bind the container's data property to the presentational component's input.
Fill all three blanks to create a container component that imports the presentational component and passes data correctly.
import { Component, inject } from '@angular/core'; import { [1] } from './presentational.component'; @Component({ selector: 'app-container', standalone: true, imports: [[2]], template: `<app-presentational [3]="data"></app-presentational>` }) export class ContainerComponent { data = 'Hello from container'; }
The container imports the presentational component class, includes it in the imports array, and uses property binding [data] to pass data.