Angular 1.5 introduced components (special kind of directive)
For directive we can write:
app.directive('myDirective',
['$timeout','$mdToast','$rootScope', // <-- injection
function ($timeout, $mdToast,$rootScope) {
return {
link: {},
//...
}
}
How can we write injection for components?
For sure I can write, something like:
app.component('myComponent', {
restrict: 'E',
bindings: {
data: '='
},
templateUrl: 'template.html',
controllerAs: 'vm',
controller: 'myComponentCtrl'
});
and:
app.controller('myComponentCtrl',
['$scope', '$timeout',
function ($scope, $timeout) {
// ....
}]);
But I want to write build-in controller, like:
app.component('myComponentCtrl', {
templateUrl: 'template.html',
controller: function($scope, $timeout) {
//...
}
});
Above mentioned style minifying (GRUNT) will brake my code Unknown provider: aProvider <- a,
So how to write properly injection for components?
Any ideas?
The demo I use Plunker