// JavaScript Controller Definition
// Application name, followed by an array of dependencies
// dependencies are similar to 'require' statements
var application = angular.module("myapp", [])
// Register a controller on our application
// Name, followed by the code for instantiating the controller
application.controller("HelloController", function($scope) {
// $scope is VERY special. We'll get to that.
$scope.hello = {};
$scope.hello.title = "World";
});
<!-- Declare the application that this view belongs to -->
<html ng-app="myapp">
<head>
<meta charset="utf-8">
<title>Hello, World!</title>
</head>
<body>
<!-- declare the controller this div (and it's children) belongs to -->
<div ng-controller="HelloController">
<!-- hello.title here, is tied to $scope.hello.title -->
<h2>Hello, {{hello.title}}!</h2>
</div>
</body>
</html>
View
HTML
Controller
JS, specifically constructed in a
.controller function
$scope
User input flows from
the view to the ctrl
Data from the program flows from the ctrl to the view