Dependency Injection



examples/angular/dependency_injection.js
angular.module('DemoApp', [])
    .controller('DemoController', ['$scope', '$log', function($scope, $log) {
        console.log($log);
        console.log($scope);
    }]);

examples/angular/dependency_injection.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport"
     content="width=device-width, initial-scale=1, user-scalable=yes">
  <script src="angular.min.js"></script>
  <script src="dependency_injection.js"></script>
</head>
<body ng-app="DemoApp" ng-controller="DemoController">
 <h1>Open the console!</h1>
 
</body>
</html>

The order of $scope and $timeout in the function call (dependency injection) must match the order in the list before.