blob: a24f959a785894d640da70e1ae93c3add540ff49 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 | @ngdoc overview
@name Cookbook: Hello World
@description
<doc:example>
 <doc:source>
  <script>
    function HelloCntl($scope) {
      $scope.name = 'World';
    }
  </script>
  <div ng-controller="HelloCntl">
    Your name: <input type="text" ng-model="name"/>
    <hr/>
    Hello {{name || "World"}}!
  </div>
 </doc:source>
 <doc:scenario>
   it('should change the binding when user enters text', function() {
     expect(binding('name')).toEqual('World');
     input('name').enter('angular');
     expect(binding('name')).toEqual('angular');
   });
 </doc:scenario>
</doc:example>
# Things to notice
Take a look through the source and note:
* The script tag that {@link guide/bootstrap bootstraps} the Angular environment.
* The text {@link api/ng.directive:input input form control} which is
  bound to the greeting name text.
* There is no need for listener registration and event firing on change events.
* The implicit presence of the `name` variable which is in the root {@link api/ng.$rootScope.Scope scope}.
* The double curly brace `{{markup}}`, which binds the name variable to the greeting text.
* The concept of {@link guide/databinding data binding}, which reflects any
changes to the
  input field in the greeting text.
 |