5.1.0
angular
5.1.0
New features
-
Added support for generic components and directives.
Type arguments can now be specified for any generic components and
directives viaTypedinstances passed to theComponentannotation's
directiveTypesparameter.@Component( selector: 'generic', template: '{{value}}', ) class GenericComponent<T> { @Input() T value; } @Component( selector: 'example', template: ''' <generic [value]="value"></generic> ''', directives: [ GenericComponent, ], directiveTypes: [ Typed<GenericComponent<String>>(), ], ) class ExampleComponent { var value = 'Hello generics!'; }
The
Typedclass also has support for typing specific component and
directive instances by#-reference, and flowing generic type parameters
from the annotated component as type arguments to its children. See its
documentation for details. -
#930: Added
@visibleForTemplatetopackage:angular/meta.dart. This
is an optional annotation that may be used to annotate elements that
should only be used from within generated code (i.e. a.template.dart).
It is a compile-time hint, which may be treated as a failing build, to use
annotated elements outside of the component or template.This annotation is intended to give component authors more control in
specifying the public API of their component(s), especially coupled with the
fact that AngularDart requires all members to be public to be reachable from
generated code. For example,candngAfterChangesare only accessible
fromCalculatorComponent(or its template) in the following:import 'package:angular/angular.dart'; import 'package:angular/meta.dart'; @Component( selector: 'calculator-comp', template: '{{a}} + {{b}} = {{c}}', ) class CalculatorComponent implements AfterChanges { @Input() num a = 0; @Input() num b = 0; @visibleForTemplate num c = 0; @override @visibleForTemplate void ngAfterChanges() { c = a + b; } }
NOTE: This feature is only enforced in SDK:
>=2.1.0-dev.3.1. -
Added support for internationalization in templates.
The
@i18nannotation marks content in document fragments or attributes for
internationalization via integration withpackage:intl.A document fragment can be internationalized by applying the
@i18n
annotation to its parent element:<div @i18n="A description of the message."> A message to be <i>translated</i>! </div>
An attribute, property, or input
<name>can be internationalized by
applying the@i18n:<name>annotation to its host element:<input placeholder="A message to be translated" @i18n:placeholder="A description of the message.">
Note that internationalization in templates currently only supports messages
with static text and HTML. See the example for more details.
Bug fixes
-
#1538: A compile-time error is reported if the
@deferredtemplate
annotation is present on a<template>element or is a sibling to a
structural directive (such as*ngIf). Before we would silently drop/ignore
the annotation, so this might be considered a breaking change of an
incorrect program. The fix is just to move the annotation, such as:<!-- Before (Both are identical) --> <template @deferred [ngIf]="showArea"> <expensive-comp></expensive-comp> </template> <expensive-comp *ngIf="showArea" @deferred></expensive-comp> <!-- After (Both are identical) --> <template [ngIf]="showArea"> <expensive-comp @deferred></expensive-comp> </template> <ng-container *ngIf="showArea"> <expensive-comp @deferred></expensive-comp> </ng-container>
-
#1558: When importing a
library.dartthat has two or more components
(i.e.Comp1andComp2), and at least one component is used@deferred
and at least one component is used without@deferred, the compiler would
generate invalid Dart code that would fail analysis/compilation to JS.
Correct code is now emitted, allowing the described scenario to work. -
#1539: Fixed a bug where components that were
@deferredas the direct
child of another<template>tag had phantom DOM left behind even after the
parent template was destroyed. For example:<template [ngIf]="showComponent"> <expensive-comp @deferred></expensive-comp> </template>
... additionally, a check for a race condition of the deferred component
being loaded after the parent view was already destroyed was added. As
a result, #1540 has also been fixed (view and content queries were not
getting reset as the@deferrednode was destroyed). -
#880: Fixed a bug where an extraneous space in
*ngFormicro expression
caused the directive to no longer be functional
(*ngFor="let x; let i = $index ", for example). -
#1570: When a provider's
tokenfor@GeneratedInjector(...)is read
asnull(either intentionally, or due to analysis errors/imports missing)
a better error message is now thrown with the context of the error. -
#434: In development mode, creating a component or service
Cthat
attempts to inject a missing dynamic dependencyDwill now throw an error
message containingCould not find provider for D: C -> D. Previously the
message was onlyCould not find provider for Din these cases, which was
often not enough information to debug easily. -
#1502: When parsing an invalid template micro expression (i.e.
*ngFor="let item of items;"- note the trailing;), throws a proper
unexpected token error instead of a confusing type error during recovery. -
#1500: Configuring a provider with
FactoryProvider(Foo, null)is now
a compile-time error, instead of a misleading runtime error. -
#1591: Using
@GenerateInjectorwith aValueProviderbound to a
Stringinstance that expects a raw string (i.er'$5.00') no longer
generates invalid code. Now all strings are emitted as raw. -
#1598: Using
@GenerateInjectorwith aValueProviderwhose value
is created as aconstobject with named arguments is now created
correctly. Before, all named arguments were skipped (left to default values,
which was oftennull). -
@GenerateInjector(...)now correctly solves duplicate tokens by having
the last, not first, provider win. This aligns the semantics with how
the other injector implementations work. ForMultiToken, the order stays
the same. -
Clarified that
Injector.map({...})doesn't supportnullas values. -
Named arguments are now supported for function calls in templates where the
function is an exported symbol (Component(exports: [someFunction])). -
#1625: Named arguments in function calls in templates that collide with
an exported symbol (Component(exports: [someExport])) no longer cause a
parsing error. -
Whitespace in internationalized message descriptions and meanings is now
normalized so they're no longer affected by formatting changes. Identical
messages with meanings that are formatted differently will now properly be
treated as the same message. -
#1633: Using a function type or any non-class
Typeinside of the
@GenerateInjector([...])annotation would cause a non-ideal error to be
produced. It now includes more information where available.
Other improvements
-
Error messages for misconfigured pipes now display their source location.
-
Assertion added for ensuring different SanitizationServices aren't used when
calling runApp multiple times. SanitizationService is a static resource so
different instances would not work as expected. -
AppViewUtils.resetChangeDetection()is now deprecated and will be removed
in the next major release.
angular_forms
2.1.0
New Features
PatternValidatornow has apatterninput. This allows thepattern
property to be set dynamically. Previously, this could only be specified
statically at compile time.
angular_test
2.1.0
New Features
-
Supported
beforeComponentCreated(Injector)when creating fixture to allow
usinginjectorto set up prerequisite data for testing from DI.This is useful when an object (that is already injected to the app) is
difficult to create otherwise. For example:// ComplexDataLayer is difficult to instantiate in test, but it is needed // to set up some fake data before the component is loaded and used. final fixture = await testBed.create( beforeComponentCreated: (i) { var dataLayer = i.get(ComplexDataLayer) as ComplexDataLayer; dataLayer.setUpMockDataForTesting(); }, );
angular_router
2.0.0-alpha+20
Bug fixes
- Fixed a discrepancy between the href rendered by
RouterLinkDirective, and
the browser location to which it would navigate upon being clicked when
usingrouterProvidersHash.
angular_compiler
0.4.1
-
Catches an (invalid)
nulltoken of a provider and throws a better error. -
Catches an (invalid)
nullvalue of the function forFactoryProvider. -
Emits all strings for
@GeneratedInjectoras raw (r'$5.00'). -
Supports named arguments for
ValueProviderand@GeneratedInjector. -
Prevents
InjectorReader.accept()from crashing when given a dependency
with no type or token.
angular_ast
0.5.7
-
Annotations may now have compound names (for example
@foo.bar). -
It is now an error to use
@deferredon a<template>tag or combined with
a structural (i.e.*ngIf) directive. -
Ignores right-trailing spaces when parsing micro expression let-assignments.
-
When parsing a failed micro expression (i.e.
*ngFor), avoids a type error. -
vellipis now a recognized char. -
Whitespace inside preformatted text (
<pre>tags) is now always preserved.