2016-06-28 09:54:42 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
|
*/
|
|
|
|
|
|
2016-09-12 09:44:20 -07:00
|
|
|
import {Provider} from '../di';
|
2016-08-10 18:21:28 -07:00
|
|
|
import {Type} from '../type';
|
2016-09-12 09:44:20 -07:00
|
|
|
import {TypeDecorator, makeDecorator} from '../util/decorators';
|
2016-06-28 09:54:42 -07:00
|
|
|
|
2016-07-25 01:39:50 -07:00
|
|
|
/**
|
|
|
|
|
* A wrapper around a module that also includes the providers.
|
|
|
|
|
*
|
2016-08-23 22:29:34 -07:00
|
|
|
* @stable
|
2016-07-25 01:39:50 -07:00
|
|
|
*/
|
|
|
|
|
export interface ModuleWithProviders {
|
2016-08-10 18:21:28 -07:00
|
|
|
ngModule: Type<any>;
|
2016-08-24 13:39:44 -07:00
|
|
|
providers?: Provider[];
|
2016-07-25 01:39:50 -07:00
|
|
|
}
|
|
|
|
|
|
2016-07-25 03:02:57 -07:00
|
|
|
/**
|
|
|
|
|
* Interface for schema definitions in @NgModules.
|
|
|
|
|
*
|
|
|
|
|
* @experimental
|
|
|
|
|
*/
|
|
|
|
|
export interface SchemaMetadata { name: string; }
|
|
|
|
|
|
|
|
|
|
/**
|
2016-08-23 10:52:40 -07:00
|
|
|
* Defines a schema that will allow:
|
2016-10-03 18:19:03 +01:00
|
|
|
* - any non-Angular elements with a `-` in their name,
|
2016-08-23 10:52:40 -07:00
|
|
|
* - any properties on elements with a `-` in their name which is the common rule for custom
|
|
|
|
|
* elements.
|
2016-07-25 03:02:57 -07:00
|
|
|
*
|
2016-08-23 22:29:34 -07:00
|
|
|
* @stable
|
2016-07-25 03:02:57 -07:00
|
|
|
*/
|
|
|
|
|
export const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata = {
|
|
|
|
|
name: 'custom-elements'
|
|
|
|
|
};
|
|
|
|
|
|
2016-08-19 16:05:34 -07:00
|
|
|
/**
|
|
|
|
|
* Defines a schema that will allow any property on any element.
|
|
|
|
|
*
|
|
|
|
|
* @experimental
|
|
|
|
|
*/
|
|
|
|
|
export const NO_ERRORS_SCHEMA: SchemaMetadata = {
|
|
|
|
|
name: 'no-errors-schema'
|
|
|
|
|
};
|
|
|
|
|
|
2016-09-12 09:44:20 -07:00
|
|
|
|
2016-07-29 02:10:30 -07:00
|
|
|
/**
|
2016-09-12 09:44:20 -07:00
|
|
|
* Type of the NgModule decorator / constructor function.
|
|
|
|
|
*
|
2016-08-23 22:29:34 -07:00
|
|
|
* @stable
|
2016-07-29 02:10:30 -07:00
|
|
|
*/
|
2016-09-12 19:14:17 -07:00
|
|
|
export interface NgModuleDecorator {
|
2016-09-12 09:44:20 -07:00
|
|
|
/**
|
|
|
|
|
* Defines an NgModule.
|
|
|
|
|
*/
|
|
|
|
|
(obj?: NgModule): TypeDecorator;
|
|
|
|
|
new (obj?: NgModule): NgModule;
|
2016-07-29 02:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
2016-06-28 09:54:42 -07:00
|
|
|
/**
|
2016-09-12 09:44:20 -07:00
|
|
|
* Type of the NgModule metadata.
|
|
|
|
|
*
|
2016-08-23 22:29:34 -07:00
|
|
|
* @stable
|
2016-06-28 09:54:42 -07:00
|
|
|
*/
|
2016-09-12 09:44:20 -07:00
|
|
|
export interface NgModule {
|
2016-06-28 09:54:42 -07:00
|
|
|
/**
|
|
|
|
|
* Defines the set of injectable objects that are available in the injector
|
|
|
|
|
* of this module.
|
|
|
|
|
*
|
|
|
|
|
* ## Simple Example
|
|
|
|
|
*
|
|
|
|
|
* Here is an example of a class that can be injected:
|
|
|
|
|
*
|
|
|
|
|
* ```
|
|
|
|
|
* class Greeter {
|
|
|
|
|
* greet(name:string) {
|
|
|
|
|
* return 'Hello ' + name + '!';
|
|
|
|
|
* }
|
|
|
|
|
* }
|
|
|
|
|
*
|
2016-07-18 03:50:31 -07:00
|
|
|
* @NgModule({
|
2016-06-28 09:54:42 -07:00
|
|
|
* providers: [
|
|
|
|
|
* Greeter
|
|
|
|
|
* ]
|
|
|
|
|
* })
|
|
|
|
|
* class HelloWorld {
|
|
|
|
|
* greeter:Greeter;
|
|
|
|
|
*
|
|
|
|
|
* constructor(greeter:Greeter) {
|
|
|
|
|
* this.greeter = greeter;
|
|
|
|
|
* }
|
|
|
|
|
* }
|
|
|
|
|
* ```
|
|
|
|
|
*/
|
2016-09-12 09:44:20 -07:00
|
|
|
providers?: Provider[];
|
2016-06-28 09:54:42 -07:00
|
|
|
|
|
|
|
|
/**
|
2016-07-18 03:50:31 -07:00
|
|
|
* Specifies a list of directives/pipes that belong to this module.
|
2016-06-28 09:54:42 -07:00
|
|
|
*
|
|
|
|
|
* ### Example
|
|
|
|
|
*
|
|
|
|
|
* ```javascript
|
2016-07-18 03:50:31 -07:00
|
|
|
* @NgModule({
|
|
|
|
|
* declarations: [NgFor]
|
2016-06-28 09:54:42 -07:00
|
|
|
* })
|
2016-07-18 03:50:31 -07:00
|
|
|
* class CommonModule {
|
2016-06-28 09:54:42 -07:00
|
|
|
* }
|
|
|
|
|
* ```
|
|
|
|
|
*/
|
2016-09-12 09:44:20 -07:00
|
|
|
declarations?: Array<Type<any>|any[]>;
|
2016-06-28 09:54:42 -07:00
|
|
|
|
|
|
|
|
/**
|
2016-07-18 03:50:31 -07:00
|
|
|
* Specifies a list of modules whose exported directives/pipes
|
|
|
|
|
* should be available to templates in this module.
|
2016-07-25 01:39:50 -07:00
|
|
|
* This can also contain {@link ModuleWithProviders}.
|
2016-06-28 09:54:42 -07:00
|
|
|
*
|
|
|
|
|
* ### Example
|
|
|
|
|
*
|
|
|
|
|
* ```javascript
|
2016-07-18 03:50:31 -07:00
|
|
|
* @NgModule({
|
|
|
|
|
* imports: [CommonModule]
|
2016-06-28 09:54:42 -07:00
|
|
|
* })
|
2016-07-18 03:50:31 -07:00
|
|
|
* class MainModule {
|
2016-06-28 09:54:42 -07:00
|
|
|
* }
|
|
|
|
|
* ```
|
|
|
|
|
*/
|
2016-09-12 09:44:20 -07:00
|
|
|
imports?: Array<Type<any>|ModuleWithProviders|any[]>;
|
2016-07-18 03:50:31 -07:00
|
|
|
|
|
|
|
|
/**
|
2016-10-03 18:19:03 +01:00
|
|
|
* Specifies a list of directives/pipes/modules that can be used within the template
|
|
|
|
|
* of any component that is part of an Angular module
|
|
|
|
|
* that imports this Angular module.
|
2016-07-18 03:50:31 -07:00
|
|
|
*
|
|
|
|
|
* ### Example
|
|
|
|
|
*
|
|
|
|
|
* ```javascript
|
|
|
|
|
* @NgModule({
|
|
|
|
|
* exports: [NgFor]
|
|
|
|
|
* })
|
|
|
|
|
* class CommonModule {
|
|
|
|
|
* }
|
|
|
|
|
* ```
|
|
|
|
|
*/
|
2016-09-12 09:44:20 -07:00
|
|
|
exports?: Array<Type<any>|any[]>;
|
2016-06-28 09:54:42 -07:00
|
|
|
|
|
|
|
|
/**
|
2016-10-03 18:19:03 +01:00
|
|
|
* Specifies a list of components that should be compiled when this module is defined.
|
|
|
|
|
* For each component listed here, Angular will create a {@link ComponentFactory}
|
|
|
|
|
* and store it in the {@link ComponentFactoryResolver}.
|
2016-06-28 09:54:42 -07:00
|
|
|
*/
|
2016-09-12 09:44:20 -07:00
|
|
|
entryComponents?: Array<Type<any>|any[]>;
|
2016-06-28 09:54:42 -07:00
|
|
|
|
2016-08-02 06:54:08 -07:00
|
|
|
/**
|
|
|
|
|
* Defines the components that should be bootstrapped when
|
|
|
|
|
* this module is bootstrapped. The components listed here
|
|
|
|
|
* will automatically be added to `entryComponents`.
|
|
|
|
|
*/
|
2016-09-12 09:44:20 -07:00
|
|
|
bootstrap?: Array<Type<any>|any[]>;
|
2016-08-02 06:54:08 -07:00
|
|
|
|
2016-08-23 10:52:40 -07:00
|
|
|
/**
|
2016-10-03 18:19:03 +01:00
|
|
|
* Elements and properties that are not Angular components nor directives have to be declared in
|
2016-08-23 10:52:40 -07:00
|
|
|
* the schema.
|
|
|
|
|
*
|
|
|
|
|
* Available schemas:
|
|
|
|
|
* - `NO_ERRORS_SCHEMA`: any elements and properties are allowed,
|
|
|
|
|
* - `CUSTOM_ELEMENTS_SCHEMA`: any custom elements (tag name has "-") with any properties are
|
|
|
|
|
* allowed.
|
|
|
|
|
*
|
|
|
|
|
* @security When using one of `NO_ERRORS_SCHEMA` or `CUSTOM_ELEMENTS_SCHEMA` we're trusting that
|
|
|
|
|
* allowed elements (and its properties) securely escape inputs.
|
|
|
|
|
*/
|
2016-09-12 09:44:20 -07:00
|
|
|
schemas?: Array<SchemaMetadata|any[]>;
|
2016-07-25 03:02:57 -07:00
|
|
|
|
2016-09-01 13:46:08 -07:00
|
|
|
/**
|
|
|
|
|
* An opaque ID for this module, e.g. a name or a path. Used to identify modules in
|
|
|
|
|
* `getModuleFactory`. If left `undefined`, the `NgModule` will not be registered with
|
|
|
|
|
* `getModuleFactory`.
|
|
|
|
|
*/
|
2016-09-12 09:44:20 -07:00
|
|
|
id?: string;
|
2016-06-28 09:54:42 -07:00
|
|
|
}
|
2016-09-12 09:44:20 -07:00
|
|
|
|
|
|
|
|
/**
|
2016-10-03 18:19:03 +01:00
|
|
|
* NgModule decorator and metadata.
|
2016-09-12 09:44:20 -07:00
|
|
|
*
|
|
|
|
|
* @stable
|
|
|
|
|
* @Annotation
|
|
|
|
|
*/
|
2017-05-23 10:52:40 -07:00
|
|
|
export const NgModule: NgModuleDecorator =
|
|
|
|
|
<NgModuleDecorator>makeDecorator('NgModule', (ngModule: NgModule) => ngModule);
|