2015-02-05 13:08:05 -08:00
|
|
|
import {CONST} from 'angular2/src/facade/lang';
|
|
|
|
|
import {DependencyAnnotation} from 'angular2/di';
|
2015-01-16 15:30:22 -08:00
|
|
|
|
2015-03-06 18:12:48 +01:00
|
|
|
/**
|
2015-04-14 23:26:49 +00:00
|
|
|
* Specifies that a function for setting host properties should be injected.
|
|
|
|
|
*
|
|
|
|
|
* NOTE: This is changing pre 1.0.
|
2015-04-14 14:34:41 -07:00
|
|
|
*
|
2015-04-14 23:26:49 +00:00
|
|
|
* The directive can inject a property setter that would allow setting this property on the host element.
|
|
|
|
|
*
|
|
|
|
|
* @exportedAs angular2/annotations
|
2015-03-06 18:12:48 +01:00
|
|
|
*/
|
|
|
|
|
export class PropertySetter extends DependencyAnnotation {
|
|
|
|
|
propName: string;
|
|
|
|
|
@CONST()
|
|
|
|
|
constructor(propName) {
|
|
|
|
|
super();
|
|
|
|
|
this.propName = propName;
|
|
|
|
|
}
|
2015-03-29 14:56:18 +02:00
|
|
|
|
|
|
|
|
get token() {
|
|
|
|
|
return Function;
|
|
|
|
|
}
|
2015-03-06 18:12:48 +01:00
|
|
|
}
|
2015-03-25 09:42:19 +01:00
|
|
|
|
|
|
|
|
/**
|
2015-04-14 23:26:49 +00:00
|
|
|
* Specifies that a constant attribute value should be injected.
|
|
|
|
|
*
|
|
|
|
|
* The directive can inject constant string literals of host element attributes.
|
|
|
|
|
*
|
|
|
|
|
* ## Example
|
|
|
|
|
*
|
|
|
|
|
* suppose we have an `<input>` element and would like to know its `type`.
|
|
|
|
|
*
|
|
|
|
|
* ```html
|
|
|
|
|
* <input type="text">
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* A decorator could inject string literal `text` like so:
|
|
|
|
|
*
|
|
|
|
|
* ```javascript
|
|
|
|
|
* @Decorator({
|
|
|
|
|
* selector: `input'
|
|
|
|
|
* })
|
|
|
|
|
* class InputDecorator {
|
|
|
|
|
* constructor(@Attribute('type') type) {
|
|
|
|
|
* // type would be `text` in this example
|
|
|
|
|
* }
|
|
|
|
|
* }
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* @exportedAs angular2/annotations
|
2015-03-25 09:42:19 +01:00
|
|
|
*/
|
|
|
|
|
export class Attribute extends DependencyAnnotation {
|
|
|
|
|
attributeName: string;
|
|
|
|
|
@CONST()
|
|
|
|
|
constructor(attributeName) {
|
|
|
|
|
super();
|
|
|
|
|
this.attributeName = attributeName;
|
|
|
|
|
}
|
2015-04-03 17:23:13 +02:00
|
|
|
|
|
|
|
|
get token() {
|
|
|
|
|
//Normally one would default a token to a type of an injected value but here
|
|
|
|
|
//the type of a variable is "string" and we can't use primitive type as a return value
|
|
|
|
|
//so we use instance of Attribute instead. This doesn't matter much in practice as arguments
|
|
|
|
|
//with @Attribute annotation are injected by ElementInjector that doesn't take tokens into account.
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2015-03-25 09:42:19 +01:00
|
|
|
}
|
2015-03-13 11:39:15 -07:00
|
|
|
|
|
|
|
|
/**
|
2015-04-14 23:26:49 +00:00
|
|
|
* Specifies that a [QueryList] should be injected.
|
|
|
|
|
*
|
|
|
|
|
* See: [QueryList] for usage.
|
|
|
|
|
*
|
|
|
|
|
* @exportedAs angular2/annotations
|
2015-03-13 11:39:15 -07:00
|
|
|
*/
|
|
|
|
|
export class Query extends DependencyAnnotation {
|
|
|
|
|
directive;
|
|
|
|
|
@CONST()
|
|
|
|
|
constructor(directive) {
|
|
|
|
|
super();
|
|
|
|
|
this.directive = directive;
|
|
|
|
|
}
|
|
|
|
|
}
|