Bird
0
0

Which of the following selectors can be used to define an Angular component?

easy📝 Conceptual Q2 of 15
Angular - Components
Which of the following selectors can be used to define an Angular component?
Aselector: 'app-header'
Bselector: '#appHeader'
Cselector: '123app'
Dselector: 'app header'
Step-by-Step Solution
Solution:
  1. Step 1: Understand Angular selector rules

    Angular component selectors must be valid CSS selectors and cannot start with a number or contain spaces.
  2. Step 2: Evaluate each option

    selector: 'app-header' is a valid element selector. selector: '#appHeader' uses an ID selector which is invalid for components. selector: '123app' starts with a number, invalid. selector: 'app header' contains a space, invalid.
  3. Final Answer:

    selector: 'app-header' -> Option A
  4. Quick Check:

    Valid CSS selector without spaces or invalid characters [OK]
Quick Trick: Component selectors must be valid CSS selectors without spaces [OK]
Common Mistakes:
  • Using spaces in selectors
  • Starting selectors with numbers
  • Using ID selectors for components

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes