Created
April 30, 2014 23:58
-
-
Save aaronroberson/38aba8e71a41d4372029 to your computer and use it in GitHub Desktop.
AngularJS Controllers Part 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Initialize the module | |
| angular.module('myModule', []); | |
| // Access the module via angular.module('myModule'); | |
| // Add the controller to the module using method chaining | |
| angular.module('myModule').controller('myController', function($scope) { | |
| // Anything added to the scope is available to the view | |
| $scope.name = 'Aaron Roberson'; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html ng-app="myModule"> | |
| <head> | |
| <script src="//code.angularjs.org/1.2.16/angular.min.js"></script> | |
| </head> | |
| <body ng-controller="myController"> | |
| <div> | |
| <label>Name:</label> | |
| <input type="text" ng-model="name" placeholder="Enter a name here"> | |
| <hr> | |
| <h1>Hello {{name}}!</h1> | |
| </div> | |
| <script src="app.js"></script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment