Simon Hunt | d7c203c | 2014-12-09 16:51:49 -0800 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html ng-app="notesApp"> |
| 3 | <head> |
| 4 | <title>Notes App</title> |
| 5 | <script src="../../tp/angular.js"></script> |
| 6 | <style> |
| 7 | span { |
| 8 | background-color: #cce; |
| 9 | } |
| 10 | </style> |
| 11 | </head> |
| 12 | <body ng-controller="MainCtrl as ctrl"> |
| 13 | |
| 14 | <!-- |
| 15 | - Note, using a form has the advantage of reacting to RETURN triggering |
| 16 | - the submit, as well as pressing the submit button. |
| 17 | --> |
| 18 | <form ng-submit="ctrl.submit()"> |
| 19 | <input type="text" placeholder="username" ng-model="ctrl.user.username"/> |
| 20 | <input type="password" placeholder="password" ng-model="ctrl.user.password"/> |
| 21 | <input type="submit" value="Submit"/> |
| 22 | <p></p> |
| 23 | <textarea cols="60" rows="5" ng-model="ctrl.user.notes" placeholder="Notes"> |
| 24 | </textarea> |
| 25 | <p> |
| 26 | NOTES: |
| 27 | <div> |
| 28 | {{ctrl.user.notes}} |
| 29 | </div> |
| 30 | </p> |
| 31 | </form> |
| 32 | |
| 33 | <script type="text/javascript"> |
| 34 | angular.module('notesApp', []) |
| 35 | .controller('MainCtrl', [function () { |
| 36 | var self = this; |
| 37 | |
| 38 | self.submit = function () { |
| 39 | console.log('User clicked submit with ', self.user); |
| 40 | }; |
| 41 | }]); |
| 42 | </script> |
| 43 | |
| 44 | </body> |
| 45 | </html> |