krzyhub krzyhub - 7 months ago 50
AngularJS Question

Angular ES6 - $inject is not a function

I just started to learn Angular ES6 way. I am analyzing this example from github:

And I tried by myselfe:

class ModalCtrl {
constructor($scope, $rootScope, app) {
$rootScope.$on('openModal', (event, data) => {
$ = data;
$scope.modalClass = 'open';

ModalCtrl.$inject(['$scope', '$rootScope', 'app']);

export default ModalCtrl;

But I get
app.min.js:60 Uncaught TypeError: ModalCtrl.$inject is not a function

What I am doing wrong and how to make this proper way?


As far I know you should use the $inject this way:

ModalCtrl.$inject = ['$scope', '$rootScope', 'app'];