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 { Provider } from '../di';
9
import { Type } from '../type';
10
import { TypeDecorator } from '../util/decorators';
11
/**
12
 * A wrapper around a module that also includes the providers.
13
 *
14
 * @stable
15
 */
16
export interface ModuleWithProviders {
17
    ngModule: Type<any>;
18
    providers?: Provider[];
19
}
20
/**
21
 * Interface for schema definitions in @NgModules.
22
 *
23
 * @experimental
24
 */
25
export interface SchemaMetadata {
26
    name: string;
27
}
28
/**
29
 * Defines a schema that will allow:
30
 * - any non-Angular elements with a `-` in their name,
31
 * - any properties on elements with a `-` in their name which is the common rule for custom
32
 * elements.
33
 *
34
 * @stable
35
 */
36
export declare const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata;
37
/**
38
 * Defines a schema that will allow any property on any element.
39
 *
40
 * @experimental
41
 */
42
export declare const NO_ERRORS_SCHEMA: SchemaMetadata;
43
/**
44
 * Type of the NgModule decorator / constructor function.
45
 *
46
 * @stable
47
 */
48
export interface NgModuleDecorator {
49
    /**
50
     * Defines an NgModule.
51
     */
52
    (obj?: NgModule): TypeDecorator;
53
    new (obj?: NgModule): NgModule;
54
}
55
/**
56
 * Type of the NgModule metadata.
57
 *
58
 * @stable
59
 */
60
export interface NgModule {
61
    /**
62
     * Defines the set of injectable objects that are available in the injector
63
     * of this module.
64
     *
65
     * ## Simple Example
66
     *
67
     * Here is an example of a class that can be injected:
68
     *
69
     * ```
70
     * class Greeter {
71
     *    greet(name:string) {
72
     *      return 'Hello ' + name + '!';
73
     *    }
74
     * }
75
     *
76
     * @NgModule({
77
     *   providers: [
78
     *     Greeter
79
     *   ]
80
     * })
81
     * class HelloWorld {
82
     *   greeter:Greeter;
83
     *
84
     *   constructor(greeter:Greeter) {
85
     *     this.greeter = greeter;
86
     *   }
87
     * }
88
     * ```
89
     */
90
    providers?: Provider[];
91
    /**
92
     * Specifies a list of directives/pipes that belong to this module.
93
     *
94
     * ### Example
95
     *
96
     * ```javascript
97
     * @NgModule({
98
     *   declarations: [NgFor]
99
     * })
100
     * class CommonModule {
101
     * }
102
     * ```
103
     */
104
    declarations?: Array<Type<any> | any[]>;
105
    /**
106
     * Specifies a list of modules whose exported directives/pipes
107
     * should be available to templates in this module.
108
     * This can also contain {@link ModuleWithProviders}.
109
     *
110
     * ### Example
111
     *
112
     * ```javascript
113
     * @NgModule({
114
     *   imports: [CommonModule]
115
     * })
116
     * class MainModule {
117
     * }
118
     * ```
119
     */
120
    imports?: Array<Type<any> | ModuleWithProviders | any[]>;
121
    /**
122
     * Specifies a list of directives/pipes/modules that can be used within the template
123
     * of any component that is part of an Angular module
124
     * that imports this Angular module.
125
     *
126
     * ### Example
127
     *
128
     * ```javascript
129
     * @NgModule({
130
     *   exports: [NgFor]
131
     * })
132
     * class CommonModule {
133
     * }
134
     * ```
135
     */
136
    exports?: Array<Type<any> | any[]>;
137
    /**
138
     * Specifies a list of components that should be compiled when this module is defined.
139
     * For each component listed here, Angular will create a {@link ComponentFactory}
140
     * and store it in the {@link ComponentFactoryResolver}.
141
     */
142
    entryComponents?: Array<Type<any> | any[]>;
143
    /**
144
     * Defines the components that should be bootstrapped when
145
     * this module is bootstrapped. The components listed here
146
     * will automatically be added to `entryComponents`.
147
     */
148
    bootstrap?: Array<Type<any> | any[]>;
149
    /**
150
     * Elements and properties that are not Angular components nor directives have to be declared in
151
     * the schema.
152
     *
153
     * Available schemas:
154
     * - `NO_ERRORS_SCHEMA`: any elements and properties are allowed,
155
     * - `CUSTOM_ELEMENTS_SCHEMA`: any custom elements (tag name has "-") with any properties are
156
     *   allowed.
157
     *
158
     * @security When using one of `NO_ERRORS_SCHEMA` or `CUSTOM_ELEMENTS_SCHEMA` we're trusting that
159
     * allowed elements (and its properties) securely escape inputs.
160
     */
161
    schemas?: Array<SchemaMetadata | any[]>;
162
    /**
163
     * An opaque ID for this module, e.g. a name or a path. Used to identify modules in
164
     * `getModuleFactory`. If left `undefined`, the `NgModule` will not be registered with
165
     * `getModuleFactory`.
166
     */
167
    id?: string;
168
}
169
/**
170
 * NgModule decorator and metadata.
171
 *
172
 * @stable
173
 * @Annotation
174
 */
175
export declare const NgModule: NgModuleDecorator;
(4-4/5)