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 viaTyped
instances passed to theComponent
annotation's
directiveTypes
parameter.@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
Typed
class 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
@visibleForTemplate
topackage: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,c
andngAfterChanges
are 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
@i18n
annotation 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
@deferred
template
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.dart
that has two or more components
(i.e.Comp1
andComp2
), 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
@deferred
as 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@deferred
node was destroyed). -
#880: Fixed a bug where an extraneous space in
*ngFor
micro expression
caused the directive to no longer be functional
(*ngFor="let x; let i = $index "
, for example). -
#1570: When a provider's
token
for@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
C
that
attempts to inject a missing dynamic dependencyD
will now throw an error
message containingCould not find provider for D: C -> D
. Previously the
message was onlyCould not find provider for D
in 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
@GenerateInjector
with aValueProvider
bound to a
String
instance that expects a raw string (i.er'$5.00'
) no longer
generates invalid code. Now all strings are emitted as raw. -
#1598: Using
@GenerateInjector
with aValueProvider
whose value
is created as aconst
object 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 supportnull
as 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
Type
inside 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
PatternValidator
now has apattern
input. 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
usinginjector
to 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)
null
token of a provider and throws a better error. -
Catches an (invalid)
null
value of the function forFactoryProvider
. -
Emits all strings for
@GeneratedInjector
as raw (r'$5.00'
). -
Supports named arguments for
ValueProvider
and@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
@deferred
on 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. -
vellip
is now a recognized char. -
Whitespace inside preformatted text (
<pre>
tags) is now always preserved.