How does AngularJS handle dependency injection, and how can it be optimized for production?

AngularJS uses dependency injection (DI) to inject services, factories, or values into components, enhancing modularity and testability. In production, DI optimization involves minification-safe annotations like ng-annotate or array-style syntax to prevent errors from variable renaming. This helps avoid runtime failures and keeps the code maintainable.

angular.module('myApp', [])
  .controller('MainController', ['$scope', 'DataService', function($scope, DataService) {
    // Controller code here
  }]);