mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
39 lines
1.2 KiB
Text
39 lines
1.2 KiB
Text
@workInProgress
|
|
@ngdoc overview
|
|
@name Cookbook: Hello World
|
|
@description
|
|
|
|
<doc:example>
|
|
<doc:source>
|
|
<script>
|
|
function HelloCntl() {
|
|
this.name = 'World';
|
|
}
|
|
</script>
|
|
<div ng:controller="HelloCntl">
|
|
Your name: <input type="text" ng:model="name" value="World"/>
|
|
<hr/>
|
|
Hello {{name}}!
|
|
</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/dev_guide.bootstrap bootstraps} the angular environment.
|
|
* The text {@link api/angular.widget.HTML input widget} which is bound to the greeting name text.
|
|
* 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/angular.scope scope}.
|
|
* The double curly brace `{{markup}}`, which binds the name variable to the greeting text.
|
|
* The concept of {@link guide/dev_guide.templates.databinding data binding}, which reflects any
|
|
changes to the
|
|
input field in the greeting text.
|