2

I just started to learn Angular ES6 way. I am analyzing this example from github: https://github.com/sitepoint-editors/Angular-ES6-BookShelf/blob/master/app/Controllers/HomeController.js

And I tried by myselfe:

class ModalCtrl {
    constructor($scope, $rootScope, app) {
        $rootScope.$on('openModal', (event, data) => {
            $scope.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?

1
  • But where? Befere constructor it does not make sense for me... Commented Aug 28, 2016 at 22:15

1 Answer 1

6

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

ModalCtrl.$inject = ['$scope', '$rootScope', 'app'];
Sign up to request clarification or add additional context in comments.

1 Comment

This is it. Thank you, because I was searching everywhere around and I was blind for those parentheses.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.