aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorTeddy Wing2017-02-03 21:40:29 +0100
committerTeddy Wing2017-02-03 21:40:29 +0100
commitd60b1eb67c2c4878955458f5378911d5d54b6a95 (patch)
treec68db2739d3e70b8829f08f7e1bbdb8884c2c9f7 /app
parenta336bc30a62f77ae8a50be5fa6deddc48ea4fba2 (diff)
downloadAngular-tutorial-d60b1eb67c2c4878955458f5378911d5d54b6a95.tar.bz2
hello.component.js: Add <input/> to edit name
Add an input to the component and use an `ng-model` to allow users to change the name in the "Hello ____" output.
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/hello/hello.component.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/assets/javascripts/hello/hello.component.js b/app/assets/javascripts/hello/hello.component.js
index d1601f2..056cd39 100644
--- a/app/assets/javascripts/hello/hello.component.js
+++ b/app/assets/javascripts/hello/hello.component.js
@@ -3,9 +3,11 @@
angular
.module('n.Hello', [])
.component('hello', {
- template: '<h2>Hello {{ $ctrl.name }}</h2>',
+ template:
+ '<h2>Hello {{ $ctrl.name }}</h2>' +
+ '<input type="text" ng-model="$ctrl.name" />',
controller: function() {
- this.name = 'World';
+ this.name = '';
}
});