Project

General

Profile

1
/**
2
 * @license
3
 * Copyright Google Inc. All Rights Reserved.
4
 *
5
 * Use of this source code is governed by an MIT-style license that can be
6
 * found in the LICENSE file at https://angular.io/license
7
 */
8
import { InjectionToken } from '../di/injection_token';
9
import { Type } from '../type';
10
/**
11
 * This token can be used to create a virtual provider that will populate the
12
 * `entryComponents` fields of components and ng modules based on its `useValue`.
13
 * All components that are referenced in the `useValue` value (either directly
14
 * or in a nested array or map) will be added to the `entryComponents` property.
15
 *
16
 * ### Example
17
 * The following example shows how the router can populate the `entryComponents`
18
 * field of an NgModule based on the router configuration which refers
19
 * to components.
20
 *
21
 * ```typescript
22
 * // helper function inside the router
23
 * function provideRoutes(routes) {
24
 *   return [
25
 *     {provide: ROUTES, useValue: routes},
26
 *     {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: routes, multi: true}
27
 *   ];
28
 * }
29
 *
30
 * // user code
31
 * let routes = [
32
 *   {path: '/root', component: RootComp},
33
 *   {path: '/teams', component: TeamsComp}
34
 * ];
35
 *
36
 * @NgModule({
37
 *   providers: [provideRoutes(routes)]
38
 * })
39
 * class ModuleWithRoutes {}
40
 * ```
41
 *
42
 * @experimental
43
 */
44
export declare const ANALYZE_FOR_ENTRY_COMPONENTS: InjectionToken<any>;
45
/**
46
 * Type of the Attribute decorator / constructor function.
47
 *
48
 * @stable
49
 */
50
export interface AttributeDecorator {
51
    /**
52
     * Specifies that a constant attribute value should be injected.
53
     *
54
     * The directive can inject constant string literals of host element attributes.
55
     *
56
     * ### Example
57
     *
58
     * Suppose we have an `<input>` element and want to know its `type`.
59
     *
60
     * ```html
61
     * <input type="text">
62
     * ```
63
     *
64
     * A decorator can inject string literal `text` like so:
65
     *
66
     * {@example core/ts/metadata/metadata.ts region='attributeMetadata'}
67
     *
68
     * ### Example as TypeScript Decorator
69
     *
70
     * {@example core/ts/metadata/metadata.ts region='attributeFactory'}
71
     *
72
     * ### Example as ES5 DSL
73
     *
74
     * ```
75
     * var MyComponent = ng
76
     *   .Component({...})
77
     *   .Class({
78
     *     constructor: [new ng.Attribute('title'), function(title) {
79
     *       ...
80
     *     }]
81
     *   })
82
     * ```
83
     *
84
     * ### Example as ES5 annotation
85
     *
86
     * ```
87
     * var MyComponent = function(title) {
88
     *   ...
89
     * };
90
     *
91
     * MyComponent.annotations = [
92
     *   new ng.Component({...})
93
     * ]
94
     * MyComponent.parameters = [
95
     *   [new ng.Attribute('title')]
96
     * ]
97
     * ```
98
     *
99
     * @stable
100
     */
101
    (name: string): any;
102
    new (name: string): Attribute;
103
}
104
/**
105
 * Type of the Attribute metadata.
106
 */
107
export interface Attribute {
108
    attributeName?: string;
109
}
110
/**
111
 * Attribute decorator and metadata.
112
 *
113
 * @stable
114
 * @Annotation
115
 */
116
export declare const Attribute: AttributeDecorator;
117
/**
118
 * Type of the Query metadata.
119
 *
120
 * @stable
121
 */
122
export interface Query {
123
    descendants: boolean;
124
    first: boolean;
125
    read: any;
126
    isViewQuery: boolean;
127
    selector: any;
128
}
129
/**
130
 * Base class for query metadata.
131
 *
132
 * See {@link ContentChildren}, {@link ContentChild}, {@link ViewChildren}, {@link ViewChild} for
133
 * more information.
134
 *
135
 * @stable
136
 */
137
export declare abstract class Query {
138
}
139
/**
140
 * Type of the ContentChildren decorator / constructor function.
141
 *
142
 * See {@link ContentChildren}.
143
 *
144
 * @stable
145
 */
146
export interface ContentChildrenDecorator {
147
    /**
148
     * @whatItDoes Configures a content query.
149
     *
150
     * @howToUse
151
     *
152
     * {@example core/di/ts/contentChildren/content_children_howto.ts region='HowTo'}
153
     *
154
     * @description
155
     *
156
     * You can use ContentChildren to get the {@link QueryList} of elements or directives from the
157
     * content DOM. Any time a child element is added, removed, or moved, the query list will be
158
     * updated,
159
     * and the changes observable of the query list will emit a new value.
160
     *
161
     * Content queries are set before the `ngAfterContentInit` callback is called.
162
     *
163
     * **Metadata Properties**:
164
     *
165
     * * **selector** - the directive type or the name used for querying.
166
     * * **descendants** - include only direct children or all descendants.
167
     * * **read** - read a different token from the queried elements.
168
     *
169
     * Let's look at an example:
170
     *
171
     * {@example core/di/ts/contentChildren/content_children_example.ts region='Component'}
172
     *
173
     * **npm package**: `@angular/core`
174
     *
175
     * @stable
176
     * @Annotation
177
     */
178
    (selector: Type<any> | Function | string, opts?: {
179
        descendants?: boolean;
180
        read?: any;
181
    }): any;
182
    new (selector: Type<any> | Function | string, opts?: {
183
        descendants?: boolean;
184
        read?: any;
185
    }): Query;
186
}
187
/**
188
 * Type of the ContentChildren metadata.
189
 *
190
 * @stable
191
 * @Annotation
192
 */
193
export declare type ContentChildren = Query;
194
/**
195
 * ContentChildren decorator and metadata.
196
 *
197
 *  @stable
198
 *  @Annotation
199
 */
200
export declare const ContentChildren: ContentChildrenDecorator;
201
/**
202
 * Type of the ContentChild decorator / constructor function.
203
 *
204
 *
205
 * @stable
206
 */
207
export interface ContentChildDecorator {
208
    /**
209
     * @whatItDoes Configures a content query.
210
     *
211
     * @howToUse
212
     *
213
     * {@example core/di/ts/contentChild/content_child_howto.ts region='HowTo'}
214
     *
215
     * @description
216
     *
217
     * You can use ContentChild to get the first element or the directive matching the selector from
218
     * the content DOM. If the content DOM changes, and a new child matches the selector,
219
     * the property will be updated.
220
     *
221
     * Content queries are set before the `ngAfterContentInit` callback is called.
222
     *
223
     * **Metadata Properties**:
224
     *
225
     * * **selector** - the directive type or the name used for querying.
226
     * * **read** - read a different token from the queried element.
227
     *
228
     * Let's look at an example:
229
     *
230
     * {@example core/di/ts/contentChild/content_child_example.ts region='Component'}
231
     *
232
     * **npm package**: `@angular/core`
233
     *
234
     * @stable
235
     * @Annotation
236
     */
237
    (selector: Type<any> | Function | string, opts?: {
238
        read?: any;
239
    }): any;
240
    new (selector: Type<any> | Function | string, opts?: {
241
        read?: any;
242
    }): ContentChild;
243
}
244
/**
245
 * Type of the ContentChild metadata.
246
 *
247
 * See {@link ContentChild}.
248
 *
249
 * @stable
250
 */
251
export declare type ContentChild = Query;
252
/**
253
 * ContentChild decorator and metadata.
254
 *
255
 * @stable
256
 * @Annotation
257
 */
258
export declare const ContentChild: ContentChildDecorator;
259
/**
260
 * Type of the ViewChildren decorator / constructor function.
261
 *
262
 * See {@link ViewChildren}.
263
 *
264
 * @stable
265
 */
266
export interface ViewChildrenDecorator {
267
    /**
268
     * @whatItDoes Configures a view query.
269
     *
270
     * @howToUse
271
     *
272
     * {@example core/di/ts/viewChildren/view_children_howto.ts region='HowTo'}
273
     *
274
     * @description
275
     *
276
     * You can use ViewChildren to get the {@link QueryList} of elements or directives from the
277
     * view DOM. Any time a child element is added, removed, or moved, the query list will be updated,
278
     * and the changes observable of the query list will emit a new value.
279
     *
280
     * View queries are set before the `ngAfterViewInit` callback is called.
281
     *
282
     * **Metadata Properties**:
283
     *
284
     * * **selector** - the directive type or the name used for querying.
285
     * * **read** - read a different token from the queried elements.
286
     *
287
     * Let's look at an example:
288
     *
289
     * {@example core/di/ts/viewChildren/view_children_example.ts region='Component'}
290
     *
291
     * **npm package**: `@angular/core`
292
     *
293
     * @stable
294
     * @Annotation
295
     */
296
    (selector: Type<any> | Function | string, opts?: {
297
        read?: any;
298
    }): any;
299
    new (selector: Type<any> | Function | string, opts?: {
300
        read?: any;
301
    }): ViewChildren;
302
}
303
/**
304
 * Type of the ViewChildren metadata.
305
 *
306
 * @stable
307
 */
308
export declare type ViewChildren = Query;
309
/**
310
 * ViewChildren decorator and metadata.
311
 *
312
 * @stable
313
 * @Annotation
314
 */
315
export declare const ViewChildren: ViewChildrenDecorator;
316
/**
317
 * Type of the ViewChild decorator / constructor function.
318
 *
319
 * See {@link ViewChild}
320
 *
321
 * @stable
322
 */
323
export interface ViewChildDecorator {
324
    /**
325
     * @whatItDoes Configures a view query.
326
     *
327
     * @howToUse
328
     *
329
     * {@example core/di/ts/viewChild/view_child_howto.ts region='HowTo'}
330
     *
331
     * @description
332
     *
333
     * You can use ViewChild to get the first element or the directive matching the selector from the
334
     * view DOM. If the view DOM changes, and a new child matches the selector,
335
     * the property will be updated.
336
     *
337
     * View queries are set before the `ngAfterViewInit` callback is called.
338
     *
339
     * **Metadata Properties**:
340
     *
341
     * * **selector** - the directive type or the name used for querying.
342
     * * **read** - read a different token from the queried elements.
343
     *
344
     * {@example core/di/ts/viewChild/view_child_example.ts region='Component'}
345
     *
346
     * **npm package**: `@angular/core`
347
     *
348
     * @stable
349
     * @Annotation
350
     */
351
    (selector: Type<any> | Function | string, opts?: {
352
        read?: any;
353
    }): any;
354
    new (selector: Type<any> | Function | string, opts?: {
355
        read?: any;
356
    }): ViewChild;
357
}
358
/**
359
 * Type of the ViewChild metadata.
360
 *
361
 * @stable
362
 */
363
export declare type ViewChild = Query;
364
/**
365
 * ViewChild decorator and metadata.
366
 *
367
 * @stable
368
 * @Annotation
369
 */
370
export declare const ViewChild: ViewChildDecorator;
(1-1/5)