diff options
| author | Teddy Wing | 2017-02-03 21:33:09 +0100 | 
|---|---|---|
| committer | Teddy Wing | 2017-02-03 21:38:54 +0100 | 
| commit | 13eb4df71a2d304d13b37cfc15eac4c76870adce (patch) | |
| tree | b14adf1040c439e148691467ff1b5f68496586bc /app | |
| parent | 8dabdf87e992755d2a2bddb99a0c464917fd42d7 (diff) | |
| download | Angular-tutorial-13eb4df71a2d304d13b37cfc15eac4c76870adce.tar.bz2 | |
Add hello.component.js
Create a new component for a Hello World example. This is housed in a
new `n.Hello` module.
For now, just print a hard-coded name to the page.
Update the `n.Notes` module adding a dependency on `n.Hello` in order
for our new component to be displayed.
Diffstat (limited to 'app')
| -rw-r--r-- | app/assets/javascripts/app.js | 2 | ||||
| -rw-r--r-- | app/assets/javascripts/hello/hello.component.js | 12 | 
2 files changed, 13 insertions, 1 deletions
| diff --git a/app/assets/javascripts/app.js b/app/assets/javascripts/app.js index c7aacc8..2f7f6ba 100644 --- a/app/assets/javascripts/app.js +++ b/app/assets/javascripts/app.js @@ -1,5 +1,5 @@  (function(angular) { -    angular.module('n.Notes', []); +    angular.module('n.Notes', ['n.Hello']);  })(window.angular); diff --git a/app/assets/javascripts/hello/hello.component.js b/app/assets/javascripts/hello/hello.component.js new file mode 100644 index 0000000..d1601f2 --- /dev/null +++ b/app/assets/javascripts/hello/hello.component.js @@ -0,0 +1,12 @@ +(function(angular) { + +    angular +        .module('n.Hello', []) +        .component('hello',  { +            template: '<h2>Hello {{ $ctrl.name }}</h2>', +            controller: function() { +                this.name = 'World'; +            } +        }); + +})(window.angular); | 
