- ng-controller
- module
- $scope
AngularJS controller with output
- Separate JavaScript from the HTML
- ng-controller
- angular.module(name, [dependencies])
- .controller
- $scope
examples/angular/hello_world_controller.html
<script src="angular.min.js"></script> <script src="hello_world_controller.js"></script> <div ng-app="HelloWorldApp"> <div ng-controller="HelloWorldController"> <h1>{{greeting}}</h1> </div> </div>
examples/angular/hello_world_controller.js
angular.module('HelloWorldApp', []) .controller('HelloWorldController', ['$scope', function($scope) { $scope.greeting = "Hello World"; }]);