Skip to content

Commit d116d86

Browse files
author
Toni Möckel
committed
Resolve Decorator
1 parent 9dffb1d commit d116d86

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/decorators.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {makePropDecorator} from "@angular/core/src/util/decorators";
2+
3+
export interface ResolveDecorator {
4+
5+
(bindingPropertyName?: string): any;
6+
new (bindingPropertyName?: string): any;
7+
}
8+
9+
export interface Resolve {
10+
/**
11+
* Name used when instantiating a component in the template.
12+
*/
13+
bindingPropertyName?: string;
14+
}
15+
16+
export const Resolve: ResolveDecorator = makePropDecorator('Resolve', [['bindingPropertyName', undefined]]);
17+
18+
19+

src/directives/uiView.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {Ng2ViewConfig} from "../statebuilders/views";
1212
import {ResolveContext, NATIVE_INJECTOR_TOKEN} from "ui-router-core";
1313
import {flattenR} from "ui-router-core";
1414
import {MergeInjector} from "../mergeInjector";
15+
import {Resolve} from "../decorators";
16+
1517

1618
/** @hidden */
1719
let id = 0;
@@ -28,6 +30,8 @@ interface InputMapping {
2830
prop: string;
2931
}
3032

33+
34+
3135
/**
3236
* Given a component class, gets the inputs of styles:
3337
*
@@ -45,7 +49,7 @@ const ng2ComponentInputs = (ng2CompClass: Type<any>) => {
4549
// -> flattened to [ { key: string, anno: annotation } ] tuples
4650
.reduce((acc, tuple) => acc.concat(tuple.annoArr.map(anno => ({ key: tuple.key, anno }))), [])
4751
// Only Inputs
48-
.filter(tuple => tuple.anno instanceof Input)
52+
.filter(tuple => tuple.anno instanceof Input || tuple.anno instanceof Resolve)
4953
// If they have a bindingPropertyName, i.e. "@Input('foo') _foo", then foo, else _foo
5054
.map(tuple => ({ token: tuple.anno.bindingPropertyName || tuple.key, prop: tuple.key }));
5155

0 commit comments

Comments
 (0)