5.0.0-alpha+6
angular
5.0.0-alpha+6
New features
-
The compiler now reports an actionable error when an annotation is used on a
private class member. -
Added
InjectionErrorandNoProviderError, which may be thrown during
dependency injection whenInjectionError.enableBetterErrorsis set to
true. This is an experiment, and we may not complete this feature (and it
could be rolled back entirely). -
Added
@GenerateInjector, a way to generate a factory for anInjector
completely at compile-time, similar to@Componentor@Directive. This
replaces the experimental feature@Injector.generate, and can be used in
conjunction with theInjectorFactoryfunction type:
import 'my_file.template.dart' as ng;
@GenerateInjector(const [
const Provider(A, useClass: APrime),
])
// The generated factory is your method's name, suffixed with `$Injector`.
final InjectorFactory example = example$Injector;- You are now able to use an
OpaqueTokenorMultiTokenas an annotation
directly instead of wrapping it in@Inject. For example, the following
classes are identically understood by AngularDart:
const baseUrl = const OpaqueToken<String>('baseUrl');
class Comp1 {
Comp1(@Inject(baseUrl) String url);
}
class Comp2 {
Comp2(@baseUrl String url);
}- You are now able to
extendOpaqueTokenorMulitTokento provide
custom application-specific injection tokens. For example, providing a
specific token for XSRF purposes:
class XsrfToken extends OpaqueToken<String> {
const XsrfToken();
}
@Component(
providers: const [
const ValueProvider.forToken(const XsrfToken(), 'ABC123'),
],
)
class Comp {
Comp(@XsrfToken() String token) {
print(token); // ABC123
}
}Breaking changes
-
Restricted the default visibility of all components and directives to
Visibility.local. This means components and directives will no longer be
available for injection by their descendants, unless their visibility is
explicitly set toVisibility.all. This feature had a cost in code size but
was rarely used, so it's now opt-in, rather than the default behavior. -
We now use a different code-path for the majority of content and view
queries, with the exception of places statically typedQueryList. While
this is not intended to be a breaking change it could have timing
implications. -
Both
COMMON_DIRECTIVESandCORE_DIRECTIVESare now deprecated, and
should be replaced bycoreDirectives. This is a no-op change (alias). -
Removed the deprecated
EventEmitterclass from the public entrypoints.
Bug fixes
-
An invalid event binding (
<comp (event-with-no-expression)>) no longer
crashes the parser during compilation and instead reports that such a
binding is not allowed. -
Corrects the behavior of
Visibility.localto match documentation.Previously, a directive with
Visibility.localwas only injectable via an
alias within its defining view. This meant the following was possibleabstract class Dependency {} @Component( selector: 'dependency', template: '<ng-content></ng-content>', providers: const [ const Provider(Dependency, useExisting: DependencyImpl), ], visibility: Visibility.local, ) class DependencyImpl implements Dependency {} @Component( selector: 'dependent', ... ) class Dependent { Dependent(Dependency _); // Injection succeeds. } @Component( selector: 'app', template: ''' <dependency> <dependent></dependent> </dependency> ''', directives: const [Dependency, Dependent], ) class AppComponent {}
because both
DependencyImplandDependentare constructed in the same
method, thus the instance ofDependencyImplcould be passed directly to
Dependentwithout an injector lookup. However, the following failed@Component( selector: 'dependency', // `Dependent` will fail to inject `Dependency`. template: '<dependent></dependent>', directives: const [Dependent], providers: const [ const Provider(Dependency, useExisting: DependencyImpl), ], visibility: Visibility.local, ) class DependencyImpl implements Dependency {}
because no code was generated for children to inject
Dependency. This was
at odds with the documentation, and optimized for a very specific use case.This has been fixed and it's now possible for all children of
DependencyImplto injectDependency, not just those constructed in the
same view. -
Services that were not marked
@Injectable()are no longer skipped when
provided inproviders: const [ ... ]for a@Directiveor@Component.
This choice made sense when@Injectable()was required, but this is no
longer the case. Additionally, the warning that was printed to console has
been removed. -
It is no longer a build warning to have an injectable service with multiple
constructors. This was originally meant to keep injection from being too
ambiguous, but there are understood patterns now (first constructor), and
there is no alternative present yet. We may re-add this as a warning if
there ends up being a mechanism to pick a constructor in the future. -
It is no longer a build warning to have injectable services or components
with named constructor parameters. While they are still not supported for
injected, they were always successfully ignored in the past, and showing a
warning to the user on every build served no purpose. -
If a
templateUrlis mispelled, a more readable exception is thrown (closes
#389):[SEVERE]: Unable to read file: "package:.../not_a_template.html" Ensure the file exists on disk and is available to the compiler.
-
If both
templateANDtemplateUrlare supplied, it is now a cleaner build
error (closes #451):[SEVERE]: Component "CompWithBothProperties" in asset:experimental.users.matanl.examples.angular.template_url_crash/lib/template_url_crash.dart: Cannot supply both "template" and "templateUrl"
-
If neither is supplied, it is also a cleaner build error:
[SEVERE]: Component "CompWithNoTemplate" in asset:experimental.users.matanl.examples.angular.template_url_crash/lib/template_url_crash.dart: Requires either a "template" or "templateUrl"; had neither.
-
If a
templateis a string that points to a file on disk, we now warn:[WARNING]: Component "CompMeantTemplateUrl" in asset:experimental.users.matanl.examples.angular.template_url_crash/lib/template_url_crash.dart: Has a "template" property set to a string that is a file. This is a common mistake, did you mean "templateUrl" instead?
-
If a private class is annotated with
@Injectable()the compiler fails. In
practice this caused a compilation error later in DDC/Dart2JS, but now the
AngularDart compiler will not emit invalid code. -
Removed spurious/incorrect warnings about classes that are used as
interfaces needing@Injectable(or needing to be non-abstract), which
are wrong and confusing. -
Fixed a case where the compiler generated incorrect code when a directive D
was applied to the host element of component C where- C implements D,
- C provides D as an alias for itself, and
- C has
Visibility.local.
Normally the local reference for C would be reused instead of creating a new
D. Giving C local visibility incorrectly prevented this assignment and
generated code to inject D from the parent injector. -
Fixed a bug where
Provider<List<T>>was treated asProvider<List>when
compiled as part of the view compiler (@Component.providers:). Now the
additional generic types flow through the compiler. -
Fixed a case where provider fields weren't type annotated. In some cases
this led to DDC warnings that are to become errors. -
The code generated for injecting a multi-token will now correctly inject a
provider that uses an existing directive withVisibility.local. This
previously failed if another existing directive withVisibility.allwas
provided for the same multi-token, after the one withVisibility.local.
angular_router
2.0.0-alpha+6
New features
Router.onNavigationStartnow emits the requested navigation path.
angular_forms
1.0.1-alpha+6
New features
- Add
markAsUntouchedmethod toAbstractControl. - Add a type annotation,
T, toAbstractControl, which is tied to the type
ofvalue. ControlGroupnowextends AbstractControl<Map<String, dynamic>>.ControlArraynowextends AbstractControl<List>.
Breaking Changes
- Changed type of
AbstractControl.statusChangesfromStream<dynamic>to
Stream<String>. This now matches the type forAbstractControl.status,
which as always been aString.
Deprecations
FormBuilderinstance methodsgroup,control, andarrayare now
deprecated. ForFormBuilder.control, just callnew Control(value, validator)directly. ForFormBuilder.groupandFormBuilder.array, use
the static methodsFormBuilder.controlGroupandFormBuilder.controlArray
respectively. In a future release,FormBuilderwill not not be
Injectable.
angular_test
2.0.0-alpha+4
-
Removed built-in support for
package:pageloader. The current version of
pageloaderrelies ondart:mirrors, which is being removed from the web
compilers (dart2js, dartdevc). There is a new (internal-only, right now)
version ofpageloaderin development that uses code generation, but it is
not available externally yet. We'll consider re-adding support once
available or through another package (i.e.angular_pageloaderor similar). -
Added
NgTestBed.forComponent, which takes aComponentFactory<T>, and
optionally anInjectorFactory. This allows writing tests entirely free of
any invocations ofinitReflector(). -
BREAKING CHANGE: Adding stabilizers to
NgTestBednow takes a factory
function of typeNgTestStabilizer Function(Injector), which is aliased as
NgTestStabilizerFactory. This allows usingNgTestBedwithout any dynamic
reflective factories (i.e.initReflector()) and doesn't have impact to
most users.
angular_compiler
0.4.0-alpha+6
New features
- Added an internal
cli.dartlibrary. Seelib/cli.dartfor details. - Added
SplitDartEmitterfor internal use. - Added
$QueryListas aTypeChecker. - Expose the
$ProviderTypeChecker.
Bug fixes
- Removed all remaining (invalid) references to
package:barback.
Breaking changes
- Added
canReadtoNgAssetReader. - Moved
CompilerFlagsandProfiletocli.dart.