A. Assigning a number to a string property 'title' causes a type error.
B. Missing @Injectable decorator on the class.
C. Template string should use backticks instead of single quotes.
D. Selector name 'app-test' is invalid.
Solution
Step 1: Check property type consistency
title is initialized as a string 'Test', but later assigned a number 123, which is a type mismatch.
Step 2: Verify other parts for errors
@Injectable is not required for components, template string with single quotes is valid, and selector 'app-test' is valid.
Final Answer:
Assigning a number to a string property 'title' causes a type error. -> Option A
Quick Check:
Property type mismatch = error [OK]
Hint: Check if property types stay consistent in constructor [OK]
Common Mistakes:
Thinking @Injectable is needed for components
Believing template string quotes cause error
Assuming selector names must be different
5. You want to build a dashboard app with multiple sections like header, sidebar, and content. Why should you use components for each section instead of writing all HTML and logic in one file?
hard
A. Because writing all code in one file is faster and recommended for large apps.
B. Because Angular requires every section to be a separate component by default.
C. Because components automatically improve app speed without any extra work.
D. Because components let you reuse, maintain, and test each section separately, making the app easier to manage.
Solution
Step 1: Understand component benefits
Components break the app into smaller parts that can be reused, tested, and maintained independently.
Step 2: Compare with single-file approach
Writing all code in one file makes it hard to manage, debug, and update as the app grows.
Final Answer:
Because components let you reuse, maintain, and test each section separately, making the app easier to manage. -> Option D
Quick Check:
Components improve manageability and reuse [OK]
Hint: Use components to split and manage app parts easily [OK]
Common Mistakes:
Thinking Angular forces components for every section