Front End Developer (AngularJS) Question:
Download Questions PDF

Explain me the concept of scope hierarchy? How many scopes can an application have?

Answer:

Each Angular application has exactly one root scope, but may have several child scopes. The application can have multiple scopes, because child controllers and some directives create new child scopes. When new scopes are created, they are added as children of their parent scope. This creates a hierarchical structure similar to the DOM where they're attached.

When Angular evaluates a bound variable like say {{firstName}}, it first looks at the scope associated with the given element for the firstName property. If no such property is found, it searches the parent scope and so on until the root scope is reached. In JavaScript this behaviour is known as prototypical inheritance, and child scopes prototypically inherit from their parents. The reverse is not true. i.e. the parent can't see it's children's bound properties.

Download Front End Developer (AngularJS) Interview Questions And Answers PDF

Previous QuestionNext Question
Tell me is AngularJS a templating system?Explain me when would you use CSS clear?