Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
7d8dce11c0 | |||
91689193bf | |||
d06636848e | |||
4e263eb391 | |||
3c684d93c8 |
@ -1,3 +1,8 @@
|
|||||||
|
<a name="10.0.14"></a>
|
||||||
|
## 10.0.14 (2020-08-26)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="10.0.12"></a>
|
<a name="10.0.12"></a>
|
||||||
## 10.0.12 (2020-08-24)
|
## 10.0.12 (2020-08-24)
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ An NgModule is defined by a class decorated with `@NgModule()`. The `@NgModule()
|
|||||||
|
|
||||||
* `imports`: Other modules whose exported classes are needed by component templates declared in *this* NgModule.
|
* `imports`: Other modules whose exported classes are needed by component templates declared in *this* NgModule.
|
||||||
|
|
||||||
* `providers`: Creators of [services](guide/architecture-services) that this NgModule contributes to the global collection of services; they become accessible in all parts of the app. (You can also specify providers at the component level, which is often preferred.)
|
* `providers`: Creators of [services](guide/architecture-services) that this NgModule contributes to the global collection of services; they become accessible in all parts of the app. (You can also specify providers at the component level.)
|
||||||
|
|
||||||
* `bootstrap`: The main application view, called the *root component*, which hosts all other app views. Only the *root NgModule* should set the `bootstrap` property.
|
* `bootstrap`: The main application view, called the *root component*, which hosts all other app views. Only the *root NgModule* should set the `bootstrap` property.
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ Every application has at least one Angular module, the _root_ module,
|
|||||||
which must be present for bootstrapping the application on launch.
|
which must be present for bootstrapping the application on launch.
|
||||||
By convention and by default, this NgModule is named `AppModule`.
|
By convention and by default, this NgModule is named `AppModule`.
|
||||||
|
|
||||||
When you use the [Angular CLI](cli) command `ng new` to generate an app, the default `AppModule` is as follows.
|
When you use the [Angular CLI](cli) command `ng new` to generate an app, the default `AppModule` looks like the following:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
/* JavaScript imports */
|
/* JavaScript imports */
|
||||||
@ -90,8 +90,6 @@ A declarable can only belong to one module, so only declare it in
|
|||||||
one `@NgModule`. When you need it elsewhere,
|
one `@NgModule`. When you need it elsewhere,
|
||||||
import the module that has the declarable you need in it.
|
import the module that has the declarable you need in it.
|
||||||
|
|
||||||
**Only `@NgModule` references** go in the `imports` array.
|
|
||||||
|
|
||||||
|
|
||||||
### Using directives with `@NgModule`
|
### Using directives with `@NgModule`
|
||||||
|
|
||||||
@ -133,7 +131,7 @@ The module's `imports` array appears exclusively in the `@NgModule` metadata obj
|
|||||||
It tells Angular about other NgModules that this particular module needs to function properly.
|
It tells Angular about other NgModules that this particular module needs to function properly.
|
||||||
|
|
||||||
This list of modules are those that export components, directives, or pipes
|
This list of modules are those that export components, directives, or pipes
|
||||||
that the component templates in this module reference. In this case, the component is
|
that component templates in this module reference. In this case, the component is
|
||||||
`AppComponent`, which references components, directives, or pipes in `BrowserModule`,
|
`AppComponent`, which references components, directives, or pipes in `BrowserModule`,
|
||||||
`FormsModule`, or `HttpClientModule`.
|
`FormsModule`, or `HttpClientModule`.
|
||||||
A component template can reference another component, directive,
|
A component template can reference another component, directive,
|
||||||
|
@ -79,7 +79,7 @@ To incorporate the feature module into your app, you have to let the root module
|
|||||||
<code-example path="feature-modules/src/app/app.module.ts" region="app-module" header="src/app/app.module.ts"></code-example>
|
<code-example path="feature-modules/src/app/app.module.ts" region="app-module" header="src/app/app.module.ts"></code-example>
|
||||||
|
|
||||||
|
|
||||||
Now the `AppModule` knows about the feature module. If you were to add any service providers to the feature module, `AppModule` would know about those too, as would any other feature modules. However, NgModules don’t expose their components.
|
Now the `AppModule` knows about the feature module. If you were to add any service providers to the feature module, `AppModule` would know about those too, as would any other feature modules. However, NgModules don’t expose their components by default.
|
||||||
|
|
||||||
|
|
||||||
## Rendering a feature module’s component template
|
## Rendering a feature module’s component template
|
||||||
|
@ -101,7 +101,7 @@ should import `BrowserModule` from `@angular/platform-browser`.
|
|||||||
`BrowserModule` provides services that are essential to launch and run a browser app.
|
`BrowserModule` provides services that are essential to launch and run a browser app.
|
||||||
|
|
||||||
`BrowserModule` also re-exports `CommonModule` from `@angular/common`,
|
`BrowserModule` also re-exports `CommonModule` from `@angular/common`,
|
||||||
which means that components in the `AppModule` module also have access to
|
which means that components in the `AppModule` also have access to
|
||||||
the Angular directives every app needs, such as `NgIf` and `NgFor`.
|
the Angular directives every app needs, such as `NgIf` and `NgFor`.
|
||||||
|
|
||||||
Do not import `BrowserModule` in any other module.
|
Do not import `BrowserModule` in any other module.
|
||||||
@ -140,7 +140,7 @@ declared in this NgModule.
|
|||||||
You _can_ export any declarable class—components, directives, and pipes—whether
|
You _can_ export any declarable class—components, directives, and pipes—whether
|
||||||
it's declared in this NgModule or in an imported NgModule.
|
it's declared in this NgModule or in an imported NgModule.
|
||||||
|
|
||||||
You _can_ re-export entire imported NgModules, which effectively re-exports all of their exported classes.
|
You _can_ re-export entire imported NgModules, which effectively re-export all of their exported classes.
|
||||||
An NgModule can even export a module that it doesn't import.
|
An NgModule can even export a module that it doesn't import.
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
@ -192,7 +192,7 @@ Its only purpose is to add http service providers to the application as a whole.
|
|||||||
|
|
||||||
The `forRoot()` static method is a convention that makes it easy for developers to configure services and providers that are intended to be singletons. A good example of `forRoot()` is the `RouterModule.forRoot()` method.
|
The `forRoot()` static method is a convention that makes it easy for developers to configure services and providers that are intended to be singletons. A good example of `forRoot()` is the `RouterModule.forRoot()` method.
|
||||||
|
|
||||||
Apps pass a `Routes` object to `RouterModule.forRoot()` in order to configure the app-wide `Router` service with routes.
|
Apps pass a `Routes` array to `RouterModule.forRoot()` in order to configure the app-wide `Router` service with routes.
|
||||||
`RouterModule.forRoot()` returns a [ModuleWithProviders](api/core/ModuleWithProviders).
|
`RouterModule.forRoot()` returns a [ModuleWithProviders](api/core/ModuleWithProviders).
|
||||||
You add that result to the `imports` list of the root `AppModule`.
|
You add that result to the `imports` list of the root `AppModule`.
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ NgModule metadata does the following:
|
|||||||
* Declares which components, directives, and pipes belong to the module.
|
* Declares which components, directives, and pipes belong to the module.
|
||||||
* Makes some of those components, directives, and pipes public so that other module's component templates can use them.
|
* Makes some of those components, directives, and pipes public so that other module's component templates can use them.
|
||||||
* Imports other modules with the components, directives, and pipes that components in the current module need.
|
* Imports other modules with the components, directives, and pipes that components in the current module need.
|
||||||
* Provides services that the other application components can use.
|
* Provides services that other application components can use.
|
||||||
|
|
||||||
Every Angular app has at least one module, the root module.
|
Every Angular app has at least one module, the root module.
|
||||||
You [bootstrap](guide/bootstrapping) that module to launch the application.
|
You [bootstrap](guide/bootstrapping) that module to launch the application.
|
||||||
|
@ -375,6 +375,5 @@ Some noteworthy observations:
|
|||||||
When you're filtering by CSS selector and only testing properties of a browser's _native element_, the `By.css` approach may be overkill.
|
When you're filtering by CSS selector and only testing properties of a browser's _native element_, the `By.css` approach may be overkill.
|
||||||
|
|
||||||
It's often easier and more clear to filter with a standard `HTMLElement` method
|
It's often easier and more clear to filter with a standard `HTMLElement` method
|
||||||
such as `querySelector()` or `querySelectorAll()`,
|
such as `querySelector()` or `querySelectorAll()`.
|
||||||
as you'll see in the next set of tests.
|
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ The tests run again, the browser refreshes, and the new test results appear.
|
|||||||
|
|
||||||
The CLI takes care of Jasmine and Karma configuration for you.
|
The CLI takes care of Jasmine and Karma configuration for you.
|
||||||
|
|
||||||
You can fine-tune many options by editing the `karma.conf.js` and
|
You can fine-tune many options by editing the `karma.conf.js` in the root folder of the project and
|
||||||
the `test.ts` files in the `src/` folder.
|
the `test.ts` files in the `src/` folder.
|
||||||
|
|
||||||
The `karma.conf.js` file is a partial Karma configuration file.
|
The `karma.conf.js` file is a partial Karma configuration file.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "angular-srcs",
|
"name": "angular-srcs",
|
||||||
"version": "10.0.12",
|
"version": "10.0.14",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Angular - a web framework for modern web apps",
|
"description": "Angular - a web framework for modern web apps",
|
||||||
"homepage": "https://github.com/angular/angular",
|
"homepage": "https://github.com/angular/angular",
|
||||||
|
@ -49,9 +49,10 @@ Zone.__load_patch('toString', (global: any) => {
|
|||||||
const originalObjectToString = Object.prototype.toString;
|
const originalObjectToString = Object.prototype.toString;
|
||||||
const PROMISE_OBJECT_TO_STRING = '[object Promise]';
|
const PROMISE_OBJECT_TO_STRING = '[object Promise]';
|
||||||
Object.prototype.toString = function() {
|
Object.prototype.toString = function() {
|
||||||
if (this instanceof Promise) {
|
if (typeof Promise === 'function' && this instanceof Promise) {
|
||||||
return PROMISE_OBJECT_TO_STRING;
|
return PROMISE_OBJECT_TO_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
return originalObjectToString.call(this);
|
return originalObjectToString.call(this);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -18,6 +18,18 @@ describe('global function patch', () => {
|
|||||||
.toEqual(Function.prototype.toString.call(g[zoneSymbol('setTimeout')]));
|
.toEqual(Function.prototype.toString.call(g[zoneSymbol('setTimeout')]));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not throw error if Promise is not a function', () => {
|
||||||
|
const P = g.Promise;
|
||||||
|
try {
|
||||||
|
g.Promise = undefined;
|
||||||
|
expect(() => {
|
||||||
|
const a = {}.toString();
|
||||||
|
}).not.toThrow();
|
||||||
|
} finally {
|
||||||
|
g.Promise = P;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('MutationObserver toString should be the same with native version',
|
it('MutationObserver toString should be the same with native version',
|
||||||
ifEnvSupports('MutationObserver', () => {
|
ifEnvSupports('MutationObserver', () => {
|
||||||
const nativeMutationObserver = g[zoneSymbol('MutationObserver')];
|
const nativeMutationObserver = g[zoneSymbol('MutationObserver')];
|
||||||
|
Reference in New Issue
Block a user