-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Streamline directive definitions with more liberal use of decorators #1800
Comments
I like the way that looks. I've been a little concerned about having a huge annotation before the class definition. This would be a good way to tie things together. I haven't looked at the decorators/annotations spec yet but I hope they're available on a method level. |
Just noticed a similar suggestion with injectables on #1451 though I see you've already found that |
I think that there is some confusion going on regarding #1451 as it mixes up configuration of the DI container with specifying what should be injected from the previously configured DI container. In this example: @Component()
class MyComponent {
@Inject(SomeServiceImpl)
constructor(someService:SomeServiceImpl) {}
} You don't really need |
Type annotation is enough only if you type on a concrete class. Agree that in that case any other info should be unnecessary. That would certainly be nice.
|
This is planned as a short hand for putting everything in |
Woo hoo! |
Actually, after creating few components I'm more and more warming up to the idea of using annotations to denote properties and events. Ex, instead of: @Component({
selector: 'bs-alert',
properties: ['type', 'dismissible'],
events: ['dismiss']
})
class BsAlert {
dismiss = new EventEmmiter();
set type(val) {...}
} I would be cool if I could write: @Component({
selector: 'bs-alert'
})
class BsAlert {
@Event()
dismiss = new EventEmmiter();
@Property()
set type(val) {...}
} The biggest advantage for me would be that I don't have to duplicate property / event names |
👍 for alternative decorator annotations |
Fixed 896add7 |
Woot! |
Update the transformer to generate code registering annotations on class properties, getters, and setters. Closes angular#1800, angular#3267, angular#4003
Update the transformer to generate code registering annotations on class properties, getters, and setters. Closes angular#1800, angular#3267, angular#4003
Update the transformer to generate code registering annotations on class properties, getters, and setters. Closes angular#1800, angular#3267, angular#4003
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
According to the docs, making a directive that listens for events on the host element is like so:
This seems like it could be streamlined:
Here's a possible alternative:
This doesn't suffer from any of the problems listed above.
You can imagine a similar streamlining for properties. Currently you write:
But using decorators you could write:
I find it a whole lot easier to understand this, not needing to remember constantly what the left and right hand side of the configuration means. E.g. for
{ 'id': 'dependency' }
I cannot tell easily which one of 'id' or 'dependency' is the JS class property and which is the DOM element property. I constantly get this confused in Angular 1, too, with the scope config. Hopefully we can eliminate this rough edge in Angular 2...The text was updated successfully, but these errors were encountered: