Angular 1.5 introduced components (special type of directive)
For the directive we can write:
app.directive('myDirective', ['$timeout','$mdToast','$rootScope', // <-- injection function ($timeout, $mdToast,$rootScope) { return { link: {}, //... } }
How can we write an injection for components?
Of course, 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 a built-in controller, for example:
app.component('myComponentCtrl', { templateUrl: 'template.html', controller: function($scope, $timeout) {
The aforementioned style styling (GRUNT) will slow down my Unknown provider: aProvider <- a
code Unknown provider: aProvider <- a
,
So how to write injections for components?
Any ideas?
In the demo I use Plunker