Complete the code to set the default change detection strategy in an Angular component.
@Component({
selector: 'app-sample',
template: `<p>Hello World</p>`,
changeDetection: ChangeDetectionStrategy.[1]
})
export class SampleComponent {}The default change detection strategy in Angular is Default. It checks the component and its children every time change detection runs.
Complete the code to import the default change detection strategy from Angular core.
import { Component, [1] } from '@angular/core'; @Component({ selector: 'app-test', template: `<p>Test</p>`, changeDetection: ChangeDetectionStrategy.Default }) export class TestComponent {}
You must import ChangeDetectionStrategy to use it in the component decorator.
Fix the error in the component decorator to use the default change detection strategy correctly.
@Component({
selector: 'app-fix',
template: `<p>Fix me</p>`,
changeDetection: [1].Default
})
export class FixComponent {}The correct enum name is ChangeDetectionStrategy. Using any other name causes an error.
Fill both blanks to complete the component decorator using the default change detection strategy and import.
import { Component, [1] } from '@angular/core'; @Component({ selector: 'app-example', template: `<p>Example</p>`, changeDetection: [2].Default }) export class ExampleComponent {}
You must import ChangeDetectionStrategy and use it in the decorator to set the default strategy.
Fill all three blanks to create a component with default change detection strategy and a simple template.
import { Component, [1] } from '@angular/core'; @Component({ selector: '[2]', template: `<p>[3]</p>`, changeDetection: ChangeDetectionStrategy.Default }) export class MyComponent {}
The import must be ChangeDetectionStrategy. The selector is a valid component name like app-my-component. The template text can be any string, here Hello Angular.