I'm using ES6 codestyle and implement a sample module like this:
import angular from 'angular';
import { IndicatorSelectorComponent } from './indicatorSelector.component';
import './indicatorSelector.css';
export const IndicatorSelectorModule = angular
.module('indicatorSelector', [])
.component('indicatorSelector', IndicatorSelectorComponent)
.name;
with this code for the component:
import templateUrl from './indicatorSelector.html';
export const IndicatorSelectorComponent = {
templateUrl,
controller: class IndicatorSelectorComponent {
contructor($http) {
'ngInject';
this.$http = $http;
}
$onInit() {
console.log(this.$http);
}
}
}
The console.log(this.$http) is returning undefined. I was suspecting that the problem was with my webpack code and ng-annotate, but I can see that the generated bunddle is including the annotation:
var IndicatorSelectorComponent = exports.IndicatorSelectorComponent = {
templateUrl: _indicatorSelector2.default,
controller: function () {
function IndicatorSelectorComponent() {
_classCallCheck(this, IndicatorSelectorComponent);
}
_createClass(IndicatorSelectorComponent, [{
key: 'contructor',
value: ["$http", function contructor($http) { // <==== HERE!
'ngInject';
this.$http = $http;
}]
}, {
key: '$onInit',
value: function $onInit() {
console.log(this.$http);
}
}]);
return IndicatorSelectorComponent;
}()
};
But still it is not working. I tried to inspect on the module code a console.log(IndicatorSelectorComponent);
I can see that $inject is empty. I don't know what else to do. I appreciate any help on this.
Object
controller :function IndicatorSelectorComponent()
$inject :Array[0]
arguments : (...)
caller : (...)
length : 0
name : "IndicatorSelectorComponent"
prototype : Object
__proto__ : function ()
[[FunctionLocation]] : indicatorSelector.component.js:5
[[Scopes]] : Scopes[3]
templateUrl : "C:/Projetos/IndicadoresPCM/client/src/app/components/goals/indicatorSelector/indicatorSelector.html"
__proto__ : Object