Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define an inline template in an Angular component.
Angular
import { Component } from '@angular/core'; @Component({ selector: 'app-inline', template: '[1]' }) export class InlineComponent {}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using backticks for inline templates is allowed but here single quotes are expected.
Confusing 'templateUrl' with 'template' property.
✗ Incorrect
The template property for inline templates uses a string with single or double quotes. Here single quotes are used around the HTML.
2fill in blank
mediumComplete the code to specify an external template file in an Angular component.
Angular
import { Component } from '@angular/core'; @Component({ selector: 'app-external', [1]: './external.component.html' }) export class ExternalComponent {}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'template' instead of 'templateUrl' for external templates.
Misspelling 'templateUrl' as 'templateFile' or 'styleUrl'.
✗ Incorrect
The 'templateUrl' property points to an external HTML file for the component's template.
3fill in blank
hardFix the error in the component decorator to correctly use an inline template.
Angular
@Component({
selector: 'app-fix',
templateUrl: '[1]'
})
export class FixComponent {} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'templateUrl' with inline HTML string causes errors.
Using backticks instead of quotes is allowed but here quotes are expected.
✗ Incorrect
For inline templates, use the 'template' property with a string containing HTML, not 'templateUrl'.
4fill in blank
hardFill both blanks to define an Angular component with an external template and inline styles.
Angular
@Component({
selector: 'app-mixed',
[1]: './mixed.component.html',
[2]: ['p { color: blue; }']
})
export class MixedComponent {} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'template' instead of 'templateUrl' for external templates.
Using 'styleUrls' instead of 'styles' for inline styles.
✗ Incorrect
Use 'templateUrl' for external HTML templates and 'styles' for inline CSS styles as an array of strings.
5fill in blank
hardFill all three blanks to create an Angular component with inline template, inline styles, and a selector.
Angular
@Component({
selector: '[1]',
template: '[2]',
styles: [ '[3]' ]
})
export class InlineFullComponent {} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing selector with template or styles.
Forgetting to wrap styles in an array.
Using external template or styles properties instead of inline.
✗ Incorrect
The selector is a string naming the component tag, template is inline HTML string, and styles is an array with CSS strings.