According to Angular documentation, the recommended way to add a dependency is by following these steps:
//inject directives and services.
var app = angular.module('fileUpload', ['ngFileUpload']);
app.controller('MyCtrl', ['$scope', 'Upload', function ($scope, Upload) {...
Can we inject a directive directly into the controller like this?
var app = angular.module('fileUpload', []);
app.controller('MyCtrl', ['ngFileUpload','$scope', 'Upload', function (ngFileUpload,$scope, Upload) {...
- If not, what is the reason for this limitation in providing such capability to controllers?
- Is there any alternative method to inject dependencies when a specific controller loads?