diff options
author | Teddy Wing | 2017-02-03 21:40:29 +0100 |
---|---|---|
committer | Teddy Wing | 2017-02-03 21:40:29 +0100 |
commit | d60b1eb67c2c4878955458f5378911d5d54b6a95 (patch) | |
tree | c68db2739d3e70b8829f08f7e1bbdb8884c2c9f7 | |
parent | a336bc30a62f77ae8a50be5fa6deddc48ea4fba2 (diff) | |
download | Angular-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.
-rw-r--r-- | app/assets/javascripts/hello/hello.component.js | 6 |
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 = ''; } }); |