@ngdoc overview
@name Developer Guide: Scopes
@description
# What are Scopes?
{@link api/ng.$rootScope.Scope scope} is an object that refers to the application
model. It is an execution context for {@link expression expressions}. Scopes are
arranged in hierarchical structure which mimic the DOM structure of the application. Scopes can
watch {@link guide/expression expressions} and propagate events.
## Scope characteristics
  - Scopes provide APIs ({@link api/ng.$rootScope.Scope#methods_$watch $watch}) to observe
    model mutations.
  - Scopes provide APIs ({@link api/ng.$rootScope.Scope#methods_$apply $apply}) to
    propagate any model changes through the system into the view from outside of the "Angular
    realm" (controllers, services, Angular event handlers).
  - Scopes can be nested to limit access to the properties of application components while providing
    access to shared model properties. Nested scopes are either "child scopes" or "isolate scopes".
    A "child scope" (prototypically) inherits properties from its parent scope. An "isolate scope"
    does not. See {@link
    guide/directive#creating-custom-directives_demo_isolating-the-scope-of-a-directive isolated
    scopes} for more information.
  - Scopes provide context against which {@link guide/expression expressions} are evaluated. For
    example `{{username}}` expression is meaningless, unless it is evaluated against a specific
    scope which defines the `username` property.
## Scope as Data-Model
Scope is the glue between application controller and the view. During the template {@link compiler
linking} phase the {@link api/ng.$compileProvider#methods_directive directives} set up
{@link api/ng.$rootScope.Scope#methods_$watch `$watch`} expressions on the scope. The
`$watch` allows the directives to be notified of property changes, which allows the directive to
render the updated value to the DOM.
Both controllers and directives have reference to the scope, but not to each other. This
arrangement isolates the controller from the directive as well as from DOM. This is an important
point since it makes the controllers view agnostic, which greatly improves the testing story of
the applications.
      {{greeting}}
    
  it('should say hello', function() {
    var scopeMock = {};
    var cntl = new MyController(scopeMock);
    // Assert that username is pre-filled
    expect(scopeMock.username).toEqual('World');
    // Assert that we read new username and greet
    scopeMock.username = 'angular';
    scopeMock.sayHello();
    expect(scopeMock.greeting).toEqual('Hello angular!');
  });
## Scope Hierarchies
Each Angular application has exactly one {@link api/ng.$rootScope root scope}, but
may have several child scopes.
The application can have multiple scopes, because some {@link guide/directive directives} create
new child scopes (refer to directive documentation to see which directives create new scopes).
When new scopes are created, they are added as children of their parent scope. This creates a tree
structure which parallels the DOM where they're attached
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.
This example illustrates scopes in application, and prototypical inheritance of properties. The example is followed by
a diagram depicting the scope boundaries.
 Notice that Angular automatically places `ng-scope` class on elements where scopes are
attached. The `
Notice that Angular automatically places `ng-scope` class on elements where scopes are
attached. The `