NG.I · Angular 22 practice question
A developer is creating a reusable UI element and wants to keep the logic (TypeScript) completely separate from the visual markup (HTML) and styling (CSS). Which configuration approach should they adopt?
@Component({
selector: 'user-card',
templateUrl: './user-card.html',
styleUrl: './user-card.css',
})
export class UserCard {}
Check answer and explanation
Correct answer: Use templateUrl and styleUrl properties to reference external files for presentation and styling.
Explanation
The developer should 'Use templateUrl and styleUrl properties to reference external files for presentation and styling.' This explicitly allows for separating the concerns of presentation from behavior.
Common trap
Defining styles inline only affects elements within that component's template, and placing styles in the class body is not a valid mechanism for styling components.
Source: Angular docs: guide/components/anatomy-of-components — guide/components/anatomy-of-components
Checked against the cited text on 2026-11-25.