- Introduce `InjectionToken<T>` which is a parameterized and type-safe
version of `OpaqueToken`.
DEPRECATION:
- `OpaqueToken` is now deprecated, use `InjectionToken<T>` instead.
- `Injector.get(token: any, notFoundValue?: any): any` is now deprecated
use the same method which is now overloaded as
`Injector.get<T>(token: Type<T>|InjectionToken<T>, notFoundValue?: T): T;`.
Migration
- Replace `OpaqueToken` with `InjectionToken<?>` and parameterize it.
- Migrate your code to only use `Type<?>` or `InjectionToken<?>` as
injection tokens. Using other tokens will not be supported in the
future.
BREAKING CHANGE:
- Because `injector.get()` is now parameterize it is possible that code
which used to work no longer type checks. Example would be if one
injects `Foo` but configures it as `{provide: Foo, useClass: MockFoo}`.
The injection instance will be that of `MockFoo` but the type will be
`Foo` instead of `any` as in the past. This means that it was possible
to call a method on `MockFoo` in the past which now will fail type
check. See this example:
```
class Foo {}
class MockFoo extends Foo {
setupMock();
}
var PROVIDERS = [
{provide: Foo, useClass: MockFoo}
];
...
function myTest(injector: Injector) {
var foo = injector.get(Foo);
// This line used to work since `foo` used to be `any` before this
// change, it will now be `Foo`, and `Foo` does not have `setUpMock()`.
// The fix is to downcast: `injector.get(Foo) as MockFoo`.
foo.setUpMock();
}
```
PR Close#13785
This commit effectively reverts 7e0f02f96e
as it was an invalid fix for #6385, that created a more significant
bug, which was that changes were not always being detected.
Angular 1 digests should be run inside the ngZone to ensure
that async changes are detected.
We don't know how to fix#6385 without breaking change detection
at this stage. That issue is triggered by async operations, such as
`setTimeout`, being triggered inside scope watcher functions.
One could argue that watcher functions should be pure and not do
work such as triggering async operations. It is possible that the
original use case could be supported by moving the debounce
logic into the watch listener function, which is only called if the
watched value actually changes.
Closes#10660, #12318, #12034
PR Close#13812
While authoring this document we agreed to pushing off the 4.0.0 release by one week by adding one more RC week (compared to the original plan).
We announced that RC would take 1 month, but then I did the calendar math incorrectly.
This schedule change will give community more time to test the release before we call it done and report any potential regression or unforeseen issues.
The change avoids the compiler CLI internal API from mismatching the following case as lazy loading
```
import { NonLazyLoadedModule } from './non-lazy-loaded/non-lazy-loaded.module';
export function getNonLazyLoadedModule() { return NonLazyLoadedModule; }
export const routes = [
{ path: '/some-path', loadChildren: getNonLazyLoadedModule }
];
```
The output of the check is later passed to `RouteDef.fromString()`, so, it makes sense to be only a string.
Fixesangular/angular-cli#3204
- remove outer `<div>` in tests,
- use `<ng-container>` instead of `<template>` where possible,
- use *... instead of template (tag or attr) where possible.
Fixes#13816
With this change the resolver is called when the parameter for the activated and any parent routes change.
ie, switching from `/teams/10/players/5` to `/teams/12/players/5` will now trigger any `PlayerResolver`.
CHANGES:
- Remove unused `onDestroy` method on the `KeyValueDiffer` and
`IterableDiffer`.
DEPRECATION:
- `CollectionChangeRecord` is renamed to `IterableChangeRecord`.
`CollectionChangeRecord` is aliased to `IterableChangeRecord` and is
marked as `@deprecated`. It will be removed in `v5.x.x`.
- Deprecate `DefaultIterableDiffer` as it is private class which
was erroneously exposed.
- Deprecate `KeyValueDiffers#factories` as it is private field which
was erroneously exposed.
- Deprecate `IterableDiffers#factories` as it is private field which
was erroneously exposed.
BREAKING CHANGE:
- `IterableChangeRecord` is now an interface and parameterized on `<V>`.
This should not be an issue unless your code does
`new IterableChangeRecord` which it should not have a reason to do.
- `KeyValueChangeRecord` is now an interface and parameterized on `<V>`.
This should not be an issue unless your code does
`new IterableChangeRecord` which it should not have a reason to do.
Original PR #12570Fixes#13382
This change adds Compiler CLI support for any level of nesting for lazy routes.
For example `{app-root}/lazy-loaded-module-1/lazy-loaded-module-2/lazy-loaded-module-3`
Where `lazy-loaded-module-3` is lazy loaded from `lazy-loaded-module-2`,
and `lazy-loaded-module-2` is lazy loaded from module `lazy-loaded-module-1`,
and `lazy-loaded-module-1` is lazy loaded from `AppModule`
Fixesangular/angular-cli#3663