Complete the code to define an Angular component with the correct decorator.
import { Component } from '@angular/core'; @Component({ selector: '[1]', template: `<h1>Hello Angular</h1>` }) export class HelloComponent {}
The selector defines the custom HTML tag for the component. app-hello is a common prefix pattern.
Complete the code to add a CSS style file to the component metadata.
@Component({
selector: 'app-style',
template: `<p>Styled text</p>`,
[1]: ['./style.component.css']
})
export class StyleComponent {}The styleUrls property links external CSS files to the component.
Fix the error in the component metadata by completing the missing property.
@Component({
selector: 'app-error',
templateUrl: './error.component.html',
[1]: ['./error.component.css']
})
export class ErrorComponent {}The correct property to link external CSS files is styleUrls. Using any other name causes Angular to ignore the styles.
Fill both blanks to define a component with inline template and styles.
@Component({
selector: 'app-inline',
[1]: `<p>Inline content</p>`,
[2]: [`p { color: blue; }`]
})
export class InlineComponent {}Use template for inline HTML and styles for inline CSS arrays.
Fill all three blanks to create a component with selector, inline template, and external styles.
@Component({
[1]: 'app-full',
[2]: `<h2>Full component</h2>`,
[3]: ['./full.component.css']
})
export class FullComponent {}The selector defines the tag, template is for inline HTML, and styleUrls links external CSS files.