53 lines
1.1 KiB
Plaintext
53 lines
1.1 KiB
Plaintext
|
|
p.location-badge.
|
|
exported from <a href='../annotations'>angular2/annotations</a>
|
|
defined in <a href="https://github.com/angular/angular/tree/2.0.0-alpha.34/modules/angular2/src/core/annotations/decorators.ts#L243-L294">angular2/src/core/annotations/decorators.ts (line 243)</a>
|
|
|
|
:markdown
|
|
<a href='Attribute-var.html'><code>Attribute</code></a> factory for creating annotations, decorators or DSL.
|
|
|
|
## Example as TypeScript Decorator
|
|
|
|
```
|
|
import {Attribute, Component, View} from "angular2/angular2";
|
|
|
|
@Component({...})
|
|
@View({...})
|
|
class MyComponent {
|
|
constructor(@Attribute('title') title: string) {
|
|
...
|
|
}
|
|
}
|
|
```
|
|
|
|
## Example as ES5 DSL
|
|
|
|
```
|
|
var MyComponent = ng
|
|
.Component({...})
|
|
.View({...})
|
|
.Class({
|
|
constructor: [new ng.Attribute('title'), function(title) {
|
|
...
|
|
}]
|
|
})
|
|
```
|
|
|
|
## Example as ES5 annotation
|
|
|
|
```
|
|
var MyComponent = function(title) {
|
|
...
|
|
};
|
|
|
|
MyComponent.annotations = [
|
|
new ng.Component({...})
|
|
new ng.View({...})
|
|
]
|
|
MyComponent.parameters = [
|
|
[new ng.Attribute('title')]
|
|
]
|
|
```
|
|
|
|
|