Bird
0
0

Consider this Angular component snippet:

medium📝 component behavior Q13 of 15
Angular - TypeScript in Angular
Consider this Angular component snippet:
export class MyComponent {
  private secret = 'hidden';
  public visible = 'shown';
}
Which property can be accessed in the component's template?
Asecret
BBoth secret and visible
Cvisible
DNeither secret nor visible
Step-by-Step Solution
Solution:
  1. Step 1: Identify access modifiers of properties

    secret is private, visible is public.
  2. Step 2: Recall template access rules

    Templates can only access public members, so only visible is accessible.
  3. Final Answer:

    visible -> Option C
  4. Quick Check:

    Only public properties are template-accessible [OK]
Quick Trick: Only public properties show in templates [OK]
Common Mistakes:
  • Assuming private properties are accessible in templates
  • Thinking both properties are accessible
  • Confusing private with protected

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes