Created
March 5, 2015 21:58
-
-
Save danharper/406e53ec4e831ae6b809 to your computer and use it in GitHub Desktop.
ngInject - define injections as a static method in your class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ngInject.js | |
function ngInject(func) { | |
if (func.ngInject)) { | |
func.$inject = func.ngInject() | |
} | |
return func | |
} | |
// Auth/LoginController.js | |
class LoginController { | |
static ngInject() { | |
return ['userSession'] | |
} | |
constructor(userSession) { | |
this._userSession = userSession | |
} | |
} | |
// Auth/index.js (the angular module definition) | |
angular.module('app.auth') | |
.controller('LoginController', ngInject(LoginController)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment