D. The styles property should be styleUrls for external CSS files
Solution
Step 1: Check the use of styles vs styleUrls
styles is for inline CSS strings; styleUrls is for external CSS files.
Step 2: Identify the mistake in the code
The code uses styles with a file path array, which is incorrect; it should be styleUrls.
Final Answer:
The styles property should be styleUrls for external CSS files -> Option D
Quick Check:
External CSS uses styleUrls, not styles = D [OK]
Hint: Use styleUrls for files, styles for inline CSS [OK]
Common Mistakes:
Confusing styles and styleUrls
Thinking styles accepts file paths
Adding @Injectable to components
5. You want to create a reusable button component with the selector app-button that uses an external HTML template and multiple CSS files. Which is the correct component decorator configuration?
hard
A. @Component({ selector: 'app-button', templateUrl: './button.html', styleUrls: ['./btn.css', './colors.css'] })
B. @Component({ selector: 'app-button', template: 'Click', styles: ['./btn.css', './colors.css'] })
C. @Component({ selector: 'app-button', templateUrl: './button.html', styles: ['./btn.css', './colors.css'] })
D. @Component({ selector: 'app-button', template: './button.html', styleUrls: ['./btn.css', './colors.css'] })
Solution
Step 1: Identify how to specify external HTML template
Use templateUrl with the path to the HTML file.
Step 2: Identify how to specify multiple external CSS files
Use styleUrls with an array of CSS file paths.
Step 3: Check each option for correct usage
The configuration using templateUrl: './button.html' and styleUrls: ['./btn.css', './colors.css'] is correct. Others incorrectly use template for a file path or styles for external CSS files.