-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Smart assign to this
in constructors
#27
Comments
TypeScript-style automatic property assignment is probably going to remain outside of the scope of this package. It would create unexpected behaviors for a lot of users, and there are many edge-cases that would be difficult to implement. However, you raise a good point that your first example does not work unless ES5 transformations are enabled, or angular.module('app').controller('Ctrl', class Ctrl {
/* @ngInject */
constructor($scope) {
//some code
}
}); However, this does (currently) work: class Ctrl {
constructor($scope) {
this.$scope = $scope;
}
dostuff() { this.foo='baz'; }
};
angular.module('app').controller('Ctrl', Ctrl); I'll keep this open as a bug until that's fixed. |
That is unfortunate. How about adding options to Something like: This is how annotations works in other languages. About the issue of |
babel-plugin-auto-assign might do the thing that you're looking for. It's not necessarily an Angular 1.x-specific feature. |
Hi @schmod. The issue you describe in the second part of #27 (comment) is exactly my problem. I was expecting this plugin to detect and convert a controller class defined inside Can you explain whether a fix is planned for this, and if not, what options I have as a workaround? What do you mean by |
could become:
The text was updated successfully, but these errors were encountered: