1 | /**
|
2 | * Annotation Factory that allows HTML style boolean attributes. For example,
|
3 | * a field declared like this:
|
4 |
|
5 | * @Directive({ selector: 'component' }) class MyComponent {
|
6 | * @Input() @BooleanFieldValueFactory() myField: boolean;
|
7 | * }
|
8 | *
|
9 | * You could set it up this way:
|
10 | * <component myField>
|
11 | * or:
|
12 | * <component myField="">
|
13 | * @deprecated
|
14 | */
|
15 | function booleanFieldValueFactory() {
|
16 | return function booleanFieldValueMetadata(target, key) {
|
17 | var defaultValue = target[key];
|
18 | var localKey = "__md_private_symbol_" + key;
|
19 | target[localKey] = defaultValue;
|
20 | Object.defineProperty(target, key, {
|
21 | get: function () { return this[localKey]; },
|
22 | set: function (value) {
|
23 | this[localKey] = value != null && "" + value !== 'false';
|
24 | }
|
25 | });
|
26 | };
|
27 | }
|
28 | export { booleanFieldValueFactory as BooleanFieldValue };
|
29 |
|
30 | //# sourceMappingURL=field-value.js.map
|