Bird
0
0

Analyze this Angular component:

medium📝 component behavior Q4 of 15
Angular - TypeScript in Angular
Analyze this Angular component:
export class ExampleComponent {
  private hiddenValue = 'secret';
  public displayValue = 'visible';
}

Which property can be directly bound and displayed in the component's template?
AdisplayValue
BhiddenValue
CBoth displayValue and hiddenValue
DNeither displayValue nor hiddenValue
Step-by-Step Solution
Solution:
  1. Step 1: Review property access modifiers

    Private properties are not accessible in templates, while public properties are accessible.
  2. Step 2: Check the properties

    hiddenValue is private, so it cannot be used in the template. displayValue is public and can be bound in the template.
  3. Final Answer:

    displayValue -> Option A
  4. Quick Check:

    Only public properties are accessible in templates [OK]
Quick Trick: Templates access only public properties [OK]
Common Mistakes:
  • Trying to bind private properties in templates
  • Assuming protected properties are accessible in templates
  • Believing both private and public are accessible

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes