dman dman - 1 year ago 71
AngularJS Question

Scope property exists in child controller when it should not

I have a child controller. In the parent controller

exist, but not in the child controller. How is it possible that
is existing in the child controller?

If you look in
expression, you will see the
exist while in the
does not have dealers.

enter image description here

Answer Source

It's a "feature" of angular scopes. Child scope prototypically inherits from the parent scope.

From - Scope Hierarchies section

When Angular evaluates {{name}}, it first looks at the scope associated with the given element for the name property. If no such property is found, it searches the parent scope and so on until the root scope is reached. In JavaScript this behavior is known as prototypical inheritance, and child scopes prototypically inherit from their parents.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download