krzyhub krzyhub - 1 month ago 9x
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'];