Skip to content

Instantly share code, notes, and snippets.

@aaronroberson
Created April 30, 2014 23:58
Show Gist options
  • Select an option

  • Save aaronroberson/38aba8e71a41d4372029 to your computer and use it in GitHub Desktop.

Select an option

Save aaronroberson/38aba8e71a41d4372029 to your computer and use it in GitHub Desktop.
AngularJS Controllers Part 1
// 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';
});
<!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