Releases: angulardart/angular
5.0.0-beta
angular
5.0.0-beta
Welcome to the first release candidate of AngularDart v5.0.0, with full support
for Dart 2. Please note that an up-to-date copy of dev
channel Dart SDK is
required (at least 2.0.0-dev.65
as of this writing) to use this version of
AngularDart. Additionally:
- Dartium is no longer supported. Instead, use the new DartDevCompiler
- Pub transformers are no longer used. Instead, use the new webdev
CLI, or, for advanced users, the build_runner CLI.
More details of changes to Dart 2 for web users
are available on our webiste.
We are no longer expecting further breaking changes as we get closer to a final
release (which itself is pending a final release of the Dart 2 SDK). Please
continue to report stability issues, bugs, or requests for small non-breaking
enhancements.
Thanks, and enjoy AngularDart!
Dependency Injection
Dependency injection was enhanced greatly for 5.0.0, primarily around using
proper types (for Dart 2), and paths to enable much smaller code size (for
everyone).
New features
-
Provider
(andprovide
) are soft deprecated, and in their place are four
new classes with more precise type signatures. Additionally,Provider
now
supports an optional type argument<T>
, making itProvider<T>
.-
ValueProvider(Type, T)
andValueProvider.forToken(OpaqueToken<T>, T)
instead ofProvider(typeOrToken, useValue: ...)
. -
FactoryProvier(Type, T)
andFactoryProvider.forToken(OpaqueToken<T>, T)
instead ofProvider(typeOrToken, useFactory: ...)
. -
ClassProvider(Type, useClass: T)
and
ClassProvider.forToken(OpaqueToken<T>, useClass: T)
instead of
Provider(typeOrToken, useClass: ...)
or an implicitType
. -
ExistingProvider(Type, T)
and
ExistingProvider.forToken(OpaqueToken<T>, T)
instead of
Provider(typeOrToken, useExisting: ...)
.
-
-
OpaqueToken
is now much more useful. Previously, it could be used to define
a custom, non-Type
to refer to something to be injected; commonly instead of
types likeString
. For example, you might use anOpaqueToken
to refer to
the a URL to download a file from:const downloadUrl = OpaqueToken('downloadUrl'); @Component( providers: [ Provider(downloadUrl, useValue: 'https://a-site.com/file.zip'), ], ) class Example { Example(@Inject(downloadUrl) String url) { // url == 'https://a-site.com/file.zip' } }
First,
OpaqueToken
adds an optional type argument, makingOpaqueToken<T>
.
The type argument,T
, should be used to refer to theType
of the object
this token should be bound to:const downloadUrl = OpaqueToken<String>('downloadUrl');
Coupled with the new named
Provider
classes and their.forToken
named
constructor (see below), you now also have a way to specify the type of
providers using type inference:@Component( providers: [ // This is now a Provider<String>. ValueProvider.forToken(downloadUrl, 'https://a-site.com/file.zip'), ], )
Second,
MultiToken<T>
has been added, and it extendsOpaqueToken<List<T>>
.
This is an idiomatic replacement for the now deprecatedmulti: true
argument to theProvider
constructor:const usPresidents = MultiToken<String>('usPresidents'); @Component( providers: [ ValueProvider.forToken(usPresidents, 'George'), ValueProvider.forToken(usPresidents, 'Abe'), ], ) class Example { Example(@Inject(usPresidents) List<String> names) { // names == ['George', 'Abe'] } }
Third, we heard feedback that the
String
-based name of tokens was
insufficient for larger teams because the names could collide. Imagine 2
different tokens being registered with a name of'importantThing'
! It is now
possible (but optional) toextend
eitherOpaqueToken
orMultiToken
to
create scoped custom token names:class DownloadUrl extends OpaqueToken<String> { const DownloadUrl(); } class UsPresidents extends MultiToken<String> { const UsPresidents(); } class Example { providers: const [ ValueProvider.forToken(DownloadUrl(), 'https://a-site.com/file.zip'), ValueProvider.forToken(UsPresidents(), 'George'), ValueProvider.forToken(UsPresidents(), 'Abe'), ], }
Fourth, and finally, we'd like to repurpose
@Inject
in the future, and let
you write less to inject tokens. So,OpaqueToken
andMultiToken
instances may now be used directly as annotations:class Example { Example(@DownloadUrl() String url, @UsPresidents() List<String> names) { // url == 'https://a-site.com/file.zip' // names == ['George', 'Abe'] } }
-
InjectorFactory
, a function type definition of
Injector Function([Injector parent])
, was added and started to be used
across the framework. It normally indicates the ability to create a new
Injector
instance with an optional parent. -
A new annotation,
@GenerateInjector
, was added. It is now posibble to
generate, at compile-time, a standaloneInjectorFactory
method for
providers, without explicitly wrapping in an@Component
:// example.dart import 'example.template.dart' as ng; @GenerateInjector([ ClassProvider(HelloService), ]) final InjectorFactory rootInjector = ng.rootInjector$Injector;
-
Module
has been added as a new, more-typed way to encapsulate a collection
ofProvider
instances. This is an optional feature to use instead of
nestedconst
lists to represent shared providers. For example:const httpModule = [ /* Other providers and/or modules. */ ]; const commonModule = [ httpModule, ClassProvider(AuthService, useClass: OAuthService), FactoryProvider.forToken(xsrfToken, useFactory: readXsrfToken), ];
... you can represent this with the new typed
Module
syntax:const httpModule = Module( /* ... Configuration ... */); const commonModule = Module( include: [httpModule], provide: [ ClassProvider(AuthService, useClass: OAuthService), FactoryProvider.forToken(xsrfToken, useFactory: readXsrfToken), ], );
The advantages here are numerous:
-
Less ambiguity around ordering of providers. Engineers would tend to try
and sort providers alphabetically, would of course, would lead to
problems.Module
specifically outlines that order is significant, and
thatinclude
is processed beforeprovide
. -
Module
rejects using aType
implicitly as aClassProvider
. This
removes additional ambiguity around supportingList<dynamic>
, and while
more verbose, should lead to more correct use. -
Module
tends to be more understandable by users of other dependency
injection systems such as Guice or Dagger, and reads better than aconst
List
(which is a very Dart-only idiom).
NOTE: It is also possible to use
Module
in@GenerateInjector
:@GenerateInjector.fromModules([ commonModule, ]) final InjectorFactory exampleFromModule = ng.exampleFromModule$Injector;
NOTE: It is also possible to use
Module
inReflectiveInjector
:// Using ReflectiveInjector is strongly not recommended for new code // due to adverse effects on code-size and runtime performance. final injector = ReflectiveInjector.resolveAndCreate([ commonModule, ]);
-
Breaking changes
-
OpaqueToken
no longer overridesoperator==
orhashCode
. In practice this
should have no effect for most programs, but it does mean that effectively
that onlyconst
instances ofOpaqueToken
(orMultiToken
) are valid. -
It is no longer valid to provide a token type of anything other than
Type
or
anOpaqueToken
(orMultiToken
). In the past anything from aribtrary
literals (such as a string -'iAmAToken'
) or a customconst
instance of a
class were supported. -
For defining whether a componenr or directive should provide itself for
injection,Visibility.none
has been renamedVisibility.local
to make it
more clear that it is accessable locally (withinproviders
for example). -
Classes annotated with
@Component
or@Directive
are no longer treated like
services annotated with@Injectable
, and not accessible (by default) to
ReflectiveInjector
.@Injectable
can always be added to these classes in
order to return to the old behavior.
Bug fixes
-
Fixed a bug where calling
get
on anInjector
injected in the context of an
@Component
or@Directive
-annotated class and passing a second argument
always returnednull
(instead of that second argument) if the token was not
found. -
Setting
@Component(visibility: Visibility.none
) no longer applies to
providers
, if any. Note thatVisibility.none
was always renamed
Visibility.local
in breaking changes above. -
Fixed a bug where
Provider(SomeType)
was not parsed correctly as an implicit
use ofProvider(SomeType, useClass: SomeType
). -
Fixed a bug where
<ReflectiveInjectior>.get(X)
would throw with a message
of no provider found for X, even when the acutal cause was a missing
downstream dependencyY
. We now emit the correct message.
Other improvements
- Some injection failures will display the chain of dependencies that were
attempted before a token was not found ('X -> Y -> Z'
) in developme...
5.0.0-alpha+15
angular
5.0.0-alpha+15
Breaking changes
- The compilation mode
--debug
(sparingly used externally) is now no longer
supported. Some flags and code paths in the compiler still check/support it
but it will be removed entirely by the final release and should no longer
be used. We will rely on assertion-based tree-shaking (fromDart2JS
)
going forward to emit debug-only conditional code.
New features
-
The
from
attribute added to<style>
tags created for component styles
now refers to the component URL, rather than its template URL. -
AngularDart now has official support of the
optional new/const feature
of Dart2. The most significant impact to the framework will be increased
terse-ness of the various metadata annotations. Please file issues if you
see any unexpected behavior. Here is one example:// Before @Component( selector: 'comp', directives: const [ FooComponent, ], providers: const [ const ClassProvider(SomeService), ], ) // After @Component( selector: 'comp', directives: [ FooComponent, ], providers: [ ClassProvider(SomeService), ], )
Bug fixes
-
Prevented a crash in
NgTemplateOutlet
caused by a specific sequence of
inputs to[ngTemplateOutlet]
. -
Relaxed type checks for events bound with a single parameter. In practice
this started failing in Dart2JS with--preview-dart-2
, potentially where
synthetic events were being passed instead of the real DOM event:<some-comp (focus)="handleFocus($event)"></some-comp>
import 'dart:html'; void handleFocus(FocusEvent e) { // Failed when 'e' was a CustomEvent or not strictly a FocusEvent. }
-
Fixed a bug where a recursive type signature on a component or directive
would cause a stack overflow. We don't support generic type arguments yet
(the reified type is alwaysdynamic
), but the compiler no longer crashes. -
Fixed a bug where
Iterable.retype
being removed from the SDK caused the
compiler to crash on the newest Dart2 -dev SDKs. We now use.cast
instead.
angular_ast
0.5.3+3
- Maintenance release for
-dev.60
.
angular_compiler
0.4.0-alpha+15
CompilerFlags
no longer parses and supports the'debug'
option and
genDebugInfo
is alwaysfalse
, and is deprecated pending removal in a
future version.
angular_forms
2.0.0-alpha+7
New Features
-
reset
method added toAbstractControl
andAbstractControlDirective
. -
RequiredValidator
now has arequired
input. This allows therequired
property to be toggled at runtime. Previously, this could only be set
statically at compile time. -
Control.invalid
getter added.
Breaking Changes
-
Remove deprecated
NG_VALUE_ACCESSOR
token. UsengValueAccessor
instead. -
Abstract
updateValue
method added toAbstractControl
. All subclasses of
AbstractControl
will need to implement this method.
angular_router
2.0.0-alpha+14
Bug fixes
-
Preserves
NavigationParams
on redirection. -
Added
canNavigate
toRouterHook
. -
Navigation will no longer succeed for an empty path if it doesn't match a
route.
angular_test
2.0.0-alpha+13
-
Removed
throwsInAngular
(was a no-op sincealpha+8
). UsethrowsA
. -
Removed
NgTestFixture#query/queryAll
, as debug-mode is being turned down. -
Added
isStable
API toNgTestStabilizer
. -
Run
DelegatingNgTestStabilizer
stabilizers one by one instead of run all
at once.update()
for each stabilizers will be run at least once. After
that, it will only be run if the current stabilizer is not stable.
5.0.0-alpha+14
angular
5.0.0-alpha+14
New features
-
In dev mode only, an attribute named
from
is now added to each<style>
tag whose value identifies the source file URL and name of the component
from which the styles originate. -
Styles that are inlined into generated
.dart
code (either in
.template.dart
or.css.dart
) now arefinal
rather thanconst
when
specified. This allows incremental compilers (such as DDC) to avoid
cascading rebuilds when only CSS styles are changed (not HTML or Dart).
Bug fixes
-
Expression conversion failures are now reported as build failures, with
source context if available, rather than as bugs in the compiler. -
Unresolved
exports
arguments in@Component
annotations will no longer
crash the compiler and are now reported as build failures.
angular_ast
0.5.3+2
- Maintenance release for
-dev.56
.
angular_compiler
0.4.0-alpha+14
- Maintenance release.
- The minimum SDK version is now
sdk: ">=2.0.0-dev.56.0 <2.0.0"
.
angular_forms
2.0.0-alpha+6
- Maintenance release.
- The minimum SDK version is now
sdk: ">=2.0.0-dev.56.0 <2.0.0"
.
angular_router
2.0.0-alpha+13
New features
- Moved
normalizePath()
from an internal type toLocation
to give
fine-grained control over path normalization.
Bug fixes
-
Fixed a regression where the
RouterLinkActive
directive would not activate
for empty paths (including'/'
). -
Fixed a bug where if a component threw an exception during routing the
router would get in a perpetual bad state where it was impossible to route
away or otherwise use the application.
angular_test
2.0.0-alpha+12
- Made
NgTestStabilizerFactory
public.
5.0.0-alpha+13
angular
5.0.0-alpha+13
Breaking changes
-
A directive with
Visibility.local
may now be injected by another directive
on the same host element, or by a descendant within the same view. -
Removed support for (deprecated)
host: const { ... }
syntax in a
@Directive
or@Component
annotation. This can be easily migrated to use
@HostBinding
or@HostListener
. -
Pins
angular_ast
andangular_compiler
to avoid future versioning issues.
angular_ast
0.5.3+1
- Fixed source span range of
AttributeAst
which would extend past EOF when
recovering from a value with an unclosed quote.
angular_compiler
0.4.0-alpha+13
- Maintenance release.
- The minimum SDK version is now
sdk: ">=2.0.0-dev.55.0 <2.0.0"
.
angular_forms
2.0.0-alpha+5
- Maintenance release.
- The minimum SDK version is now
sdk: ">=2.0.0-dev.55.0 <2.0.0"
.
angular_router
2.0.0-alpha+12
Breaking changes
- Renamed the
platformStrategy
field ofLocation
tolocationStrategy
,
since it's of typeLocationStrategy
.
angular_test
2.0.0-alpha+11
-
Fixed a bug where a
WillNeverStabilizeError
was thrown whenever there was
a non-zero lengthTimer
being executed. This was due to a bug in how the
NgStabilizer
was executing - constantly calling theupdate
function
instead of calling it once and waiting for stabilization. -
Fixed a bug where stabilizers are considered stable even when some of them
are not.
5.0.0-alpha+12
angular
5.0.0-alpha+12
Breaking changes
-
It is now a compile-time error to place a
@HostBinding
or@HostListener
annotation on a class member that does not accept the respective annotation.
For example, the following snippet will break at compile-time:class Comp { // Deceptively, this did not do *anything* before, but the user was never // told that the annotation was effectively a no-op. It will fail now! @HostListener('click') Function onClick; }
... as part of this refactor, error messages in general around use of
these annotations have been greatly improved. -
The semantics of
@Component(preserveWhitespace: false)
(the default flag)
have changed somewhat in this release due to user feedback both internally
and externally (see #804). The
easiest way to explain the changes are with this example:Foo <strong>Bar</strong> Baz
... used to display "FooBarBaz" in the old semantics, and now displays
"Foo Bar Baz" in the new semantics. There are some cases where
generated code is slightly larger, and other cases where it is smaller (we
have some smarter heuristics around safe places to collapse whitespace).
New features
-
Added
<ng-container>
, an element for logical grouping that has no effect
on layout. This enables use of the *-syntax for structural directives,
without requiring the cost an HTML element.Before
<ul> <template ngFor let-user [ngForOf]="users"> <li *ngIf="user.visible">{{user.name}}</li> </template> </ul>
After
<ul> <ng-container *ngFor="let user of users"> <li *ngIf="user.visible">{{user.name}}</li> </ng-container> </ul>
-
.ng_placeholder
files will be excluded from--output
builds..css
and
.html
files will be excluded by default from thelib/
directory for
release builds. Disable entirely with:targets: $default: angular|component_source_cleanup: options: enabled: false
or exclude some sources by glob:
targets: $default: angular|component_source_cleanup: options: exclude: - "lib/non_angular_style.css" - "lib/something/**"
-
@HostBinding()
forstatic
const
orfinal
fields are set at build
time rather than being change-detected.
Bug fixes
-
Inheriting from a class that defines a
@HostBinding()
on a static member
no longer causes the web compiler (Dartdevc or Dart2JS) to fail. We
previously inherited these bindings and generated invalid Dart code. Given
that static members are not inherited in the Dart language, it made sense
to give a similar treatment to these annotations. Instance-level members are
still inherited:class Base { @HostBinding('title') static const hostTitle = 'Hello'; @HostBinding('class') final hostClass = 'fancy'; } // Will have DOM of <fancy-button class="fancny"> but *not* title="Hello". @Component( selector: 'fancy-button', template: '...', ) class FancyButton extends Base {}
-
Styles from an
@import
statement are now included before the styles
declared within the file, instead of after. This allows a style declared
within a file to override an imported one of equivalent specificity. -
URLs from
@import
statements with thepackage
scheme are no longer
resolved to thepackages/
directory. Thepackage
scheme is now preserved
which the build ecosystem understands. -
In
ReflectiveInjector
,.injectFromSelfOptional
now checks if it is truly
a instance cache misses before creating a new instance.
angular_ast
0.5.3
-
Exported
ParsedAnnotationAst
. -
Added
ContainerAst
. -
Annotations may now be assigned values.
-
Added support for annotations on
ContainerAst
. -
The
*
micro-syntax now supports leading whitespace. -
Whitespace between
<ng-content>
and</ng-content>
will no longer yield a
parsing error.
angular_compiler
0.4.0-alpha+12
- Removes unused APIs of
ComponentReader
. - Added
DirectiveVisitor
, and removed$HostBinding
and$HostListener
.
angular_forms
2.0.0-alpha+4
New Features
Control.markAsPristine
added. This will clear thedirty
property.
Breaking Changes
-
NgControlName
will no longer initialize withnull
if a value is
specified by 'ngModel'. -
The
touched
property ofControl
s is now propagated to parents /
children.
Bug fixes
- Add a not selector to ngForm for memorizedForm since memorized_form is now
in angular_forms. This fixes the DIRECTIVE_EXPORTED_BY_AMBIGIOUS error when
using: <form #form="ngForm" memorizedForm>
angular_test
2.0.0-alpha+10
- Fixed a bug where
_createDynamic
does not preserverootInjector
.
5.0.0-alpha+11
angular
5.0.0-alpha+11
Breaking changes
-
Removed
ApplicationRef.injector
from the public API. This was a sparingly
used API, and it was usually incorrect to specifically use this injector
over the current injector in the component context or the root component's
Injector
. -
Removed the experimental
parent
argument toApplicationRef.bootstrap
.
It is no longer needed since all applications use the same bootstrap code
branch (eitherrunApp
, or code that eventually runs throughrunApp
). -
Removed the rarely used
template
attribute syntax. Uses can be replaced
with either the*
micro-syntax, or a<template>
element.Before
<div template="ngFor let item of items; trackBy: trackById; let i=index"> {{i}}: {{item}} </div>
After
<!-- * micro-syntax --> <div *ngFor="let item of items; trackBy: trackById; let i=index"> {{i}}: {{item}} </div> <!-- <template> element --> <template ngFor let-item [ngForOf]="items" [ngForTrackBy]="trackById" let-i="index"> <div> {{i}}: {{item}} </div> </template>
New features
-
The new
Module
syntax for dependency injection is shipped! This is an
optional feature instead of using nestedconst
lists to represent sets
of shared providers. For example, instead of the following:const httpModule = const [ /* Other providers and/or modules. */ ]; const commonModule = const [ httpModule, const ClassProvider(AuthService, useClass: OAuthService), const FactoryProvider.forToken(xsrfToken, useFactory: readXsrfToken), ];
... you can represent this with the new typed
Module
syntax:const httpModule = const Module( /* ... Configuration ... */); const commonModule = const Module( include: const [httpModule], provide: const [ const ClassProvider(AuthService, useClass: OAuthService), const FactoryProvider.forToken(xsrfToken, useFactory: readXsrfToken), ], );
The advantages here are numerous:
-
Less ambiguity around ordering of providers. Engineers would tend to try
and sort providers alphabetically, would of course, would lead to
problems.Module
specifically outlines that order is significant, and
thatinclude
is processed beforeprovide
. -
Module
rejects using aType
implicitly as aClassProvider
. This
removes additional ambiguity around supportingList<dynamic>
, and while
more verbose, should lead to more correct use. -
Module
tends to be more understandable by users of other dependency
injection systems such as Guice or Dagger, and reads better than aconst
List
(which is a very Dart-only idiom).
We're not yet updating the [style guide]
(https://github.com/dart-lang/angular/blob/master/doc/effective/di.md) in
this release, but we are looking for users to help validate that this is
the way to go for the future.NOTE: It is also possible to use
Module
in@GenerateInjector
:@GenerateInjector.fromModules(const [ const Module( include: const [ const Module( provide: const [ const ValueProvider(ExampleService, const ExampleService()), ], ), ], provide: const [ const ValueProvider(ExampleService2, const ExampleService2()), const ExistingProvider(ExampleService, ExampleService2), ], ), ]) final InjectorFactory exampleFromModule = ng.exampleFromModule$Injector;
NOTE: It is also possible to use
Module
inReflectiveInjector
:// Using ReflectiveInjector is strongly not recommended for new code // due to adverse effects on code-size and runtime performance. final injector = ReflectiveInjector.resolveAndCreate([ const Module( include: const [ const Module( provide: const [ const ValueProvider(ExampleService, const ExampleService()), ], ), ], provide: const [ const ValueProvider(ExampleService2, const ExampleService2()), const ExistingProvider(ExampleService, ExampleService2), ], ), ]);
-
-
@HostListener()
can now automatically infer theconst ['$event']
parameter when it is omitted but the bound method has a single argument:class Comp { @HostListener('click') void onClick(MouseEvent e) {} }
Bug fixes
-
The
*
micro-syntax now supports newlines after an identifier. -
The compiler is now reporting errors again for invalid property bindings on
<template>
elements.
angular_ast
0.5.2
- The
*
micro-syntax now supports newlines after an identifier.
angular_compiler
0.4.0-alpha+11
- Added
ModuleReader.extractProviderObjects
to use in the view compiler. - Added
logFine
as a new top-level API.
angular_forms
2.0.0-alpha+3
New Features
- Add
ngDisabled
input to all Control directives.
Breaking Changes
-
NgControlGroup
can no longer be injected directly. It can still be
injected as aControlContainer
. -
NgControlName
andNgFormControl
can no longer be injected directly. They
can still be injected as aNgControl
. -
CheckboxControlValueAccessor
,DefaultValueAccessor
,
NumberValueAccessor
,RadioControlValueAccessor
, andNgSelectOption
can
no longer be injected directly.
angular_router
2.0.0-alpha+11
New features
- Added the method
navigateByUrl
toRouter
.
angular_test
2.0.0-alpha+9
pub run angular_test
was entirely removed. This hasn't worked since
2.0.0-alpha+3
, but instead threw an error message reminding users it was
no longer supported.
5.0.0-alpha+10
angular
5.0.0-alpha+10
Breaking changes
-
The minimum SDK version is now
sdk: ">=2.0.0-dev.46.0 <2.0.0"
. -
The process for starting your AngularDart application changed significantly:
-
For most applications, we recommend now strongly recommend using the new
runApp
function. Instead of starting your application by passing the
Type
of an@Component
-annotatedclass
, you now pass a
ComponentFactory
, the generated code for a component:import 'package:angular/angular.dart'; // ignore: uri_has_not_been_generated import 'main.template.dart' as ng; void main() { runApp(ng.RootComponentNgFactory); } @Component( selector: 'root', template: 'Hello World', ) class RootComponent {}
To provide top-level services, use the
createInjector
parameter, and
pass a generatedInjectorFactory
for a top-level annotated with
@GenerateInjector
:import 'package:angular/angular.dart'; // ignore: uri_has_not_been_generated import 'main.template.dart' as ng; void main() { runApp(ng.RootComponentNgFactory, createInjector: rootInjector); } class HelloService { void sayHello() => print('Hello!'); } @GenerateInjector(const [ const ClassProvider(HelloService), ]) final InjectorFactory rootInjector = ng.rootInjector$Injector;
A major difference between
runApp
and previous bootstrapping code is
the lack of theinitReflector()
method or call, which is no longer
needed. That means usingrunApp
disables the use of
SlowComponentLoader
andReflectiveInjector
, two APIs that require
this extra runtime metadata.To enable use of these classes for migration purposes, use
runAppLegacy
:import 'package:angular/angular.dart'; // ignore: uri_has_not_been_generated import 'main.template.dart' as ng; void main() { runAppLegacy( RootComponent, createInjectorFromProviders: [ const ClassProvider(HelloService), ], initReflector: ng.initReflector, ); }
NOTE:
initReflector
andrunAppLegacy
disables tree-shaking on
any class annotated with@Component
or@Injectable
. We strongly
recommend migrating to therunApp
pattern. -
The
APP_INITIALIZERS
token was removed. The closest functionality
(running a function that returns aFuture
before creating the root
component) is usingrunAppAsync
orrunAppLegacyAsync
functions with
abefofreComponentCreated
callback:import 'dart:async'; import 'package:angular/angular.dart'; // ignore: uri_has_not_been_generated import 'main.template.dart' as ng; Future<String> fetchSomeText() => ... void main() { runApp( ng.RootComponentNgFactory, beforeComponentCreated: (injector) { final prefetch = injector.get(Prefetch) as Prefetch; return prefetch.prefetchSomeData(); }, // @GenerateInjector could be used instead. This is a simple example. createInjector: (parent) { return new Injector.map({ Prefetch: new Prefetch(); }, parent); }, ); } @Component( selector: 'root', template: 'Hello World', ) class RootComponent {} class Prefetch { Future<void> prefetchSomeData() => ... }
-
The top-level function
bootstrap
was deleted. This function always
threw a runtime exception since5.0.0-alpha+5
, and was a relic of when
a code transformer rewrote it automatically asbootstrapStatic
. -
The top-level function
bootstrapStatic
is now deprecated. The
closest equivalent is the newrunAppLegacy
_orrunAppLegacyAsync
functions.
-
-
The interface
PlatformRef
(andPlatformRefImpl
) were removed. They were
not used, and added an unnecessary code-size overhead to every application. -
Removed the deprecated
QueryList
class,List
is used instead, only. -
Removed
ApplicationRef.registerBootstrapListener
, which was unused.
New features
-
The compiler now warns when a
@Component.styles
seems to reference a file
on disk, such asstyles: const ['a.css']
(this is usually an accident). We
already warned fortemplate: 'a.html'
. -
Running within an angular zone will no longer cause addtional turns to occur
within it's parent's zone. ngZone's run() will now run inside the parent
zone's run() function as opposed to the other way around.
Internal cleanup
- Add explicit error for when angular codegen is not invoked, the previous
error was "Could not find a factory for X" but this is not the real issue
since none of the factories had been loaded due to lack of angular codegen.
angular_ast
0.5.1
-
The minimum SDK version is now
sdk: ">=2.0.0-dev.46.0 <2.0.0"
. -
The
*
micro-syntax now supports binding to the primary input when followed
by additional input orlet
bindings. Previously the micro-syntax supported
binding to the primary input only in isolation.Example usage enabled by this change.
Before:
<template [foo]="expr1" [fooContext]="expr2"> <div></div> </template>
After:
<div *foo="expr1; context: expr2"></div>
angular_compiler
0.4.0-alpha+10
- Maintenance release.
- The minimum SDK version is now
sdk: ">=2.0.0-dev.46.0 <2.0.0"
.
angular_forms
2.0.0-alpha+2
Breaking Changes
-
The minimum SDK version is now
sdk: ">=2.0.0-dev.46.0 <2.0.0"
. -
Add
ControlValueAccessor.onDisabledChanged()
method. All implementations
ofControlValueAccessor
need to add this method. -
Remove
include
andexclude
methods fromControlGroup
. These can be
replaced with calls tomarkAsEnabled
andmarkAsDisabled
instead.Before:
controlGroup.include('foo');
After:
controlGroup.controls['foo'].markAsEnabled();
-
CheckboxControlValueAccessor
now implementsControlValueAccessor<bool>
andRadioControlValueAccessor
now implements
ControlValueAccessor<RadioButtonState>
. Previously, they were both
ControlValueAccessor<dynamic>
.
angular_router
2.0.0-alpha+10
Breaking changes
- The minimum SDK version is now
sdk: ">=2.0.0-dev.46.0 <2.0.0"
.
Bug fixes
- Router navigation requests are now queued to ensure they'll run sequentially
in the order they were requested. Previously no attempt was made to
synchronise navigation requests, and if multiple were made simultaneously
they could run concurrently, interfere with each other, and potentially
complete out of order.
angular_test
2.0.0-alpha+8
-
The minimum SDK version is now
sdk: ">=2.0.0-dev.46.0 <2.0.0"
. -
DEPRECATED:
throwsInAngular
is now a no-op, and can be removed.
5.0.0-alpha+9
angular
5.0.0-alpha+9
New features
-
Static properties and methods of a component may now be referenced without a
receiver in the component's own template.Before:
ExampleComponent
as receiver is necessary.@Component( selector: 'example', template: '<h1>{{ExampleComponent.title}}</h1>', ) class ExampleComponent { static String title; }
After: No receiver is necessary.
@Component( selector: 'example', template: '<h1>{{title}}</h1>', ) class ExampleComponent { static String title; }
Breaking changes
-
The field
COMMON_PIPES
has been renamed tocommonPipes
. -
The field
zone
inApplicationRef
has been removed from the API. -
The token
PLATFORM_INITIALIZERS
has been removed. This was used sparingly to
run functions before the application was started, but can just as easily be
converted into running functions inmain()
before. -
The token
APP_INITIALIZER
is now DEPRECATED. It was used sparingly,
and can easily be replaced by running functions in your root component with
an*ngIf
guard for initialization. -
Methods in lifecycle hooks have
void
return type. This is breaking change
if the override doesn't specify return type and usesreturn
without any
value. To fix add avoid
orFuture<void>
return type to the override:class MyComp implements OnInit { @override void ngOnInit() { // ... } }
-
Removed deprecated
ComponentResolver
class. -
Removed deprecated
componentFactories
andcomponentTypes
getters from
theApplicationRef
class. These were used internally by the legacy router
and were not intended to be parts of the public API.
Bug fixes
-
String literals bound in templates now support Unicode escapes of the form
\u{?-??????}
. This enables support for Unicode supplementary planes, which
includes emojis! -
Using
@GenerateInjector
with aValueProvider
where the value is either a
top-level function or static-class method no longer crashes.
Internal cleanup
- Template normalization in the compiler now uses the newer template parser
based onpackage:angular_ast
. There is no flag to enable the old behavior
but please reach out if you see issues in this release.
angular_ast
0.5.0
-
BREAKING CHANGE: We no longer support parsing Dart expressions as part
of parsing the template AST. We hope to re-add some support for this by
migrating the existing parser inpackage:angular
, but we are likely not to
have a stable API for some time. -
BREAKING CHANGE: Deleted
ExpressionParserVisitor
(related to above).
angular_compiler
0.4.0-alpha+9
Breaking changes
TokenReader
no longer supports arbitrary const objects or literals.
Bug Fixes
- Fixed a bug where the compiler crashed after resolving a bound type failed.
angular_forms
2.0.0-alpha+1
New Features
- Add
MemorizedForm
directive. This is a form that will not remove controls
if the control is taken out of the view, for example with a [NgIf].
Breaking Changes
- Remove
optionals
param fromControlGroup
constructor. This will soon be
replaced bydisabled
state for allControls
. See
#1037 for more details.
angular_router
2.0.0-alpha+9
Breaking changes
-
APP_BASE_HREF
was removed in favor ofappBaseHref
. -
When navigating to and from the same implementation of
CanReuse
, if it
returns true, the implementation will remain attached to the DOM.
Previously, components were unconditionally detached from the DOM on
navigation, and reusable components would simply be reattached.This may be a change to the scroll behavior of your components, as
temporarily removing reused components from the DOM could reset the scroll
position if no other content was present.
Bug fixes
CanNavigate
,CanDeactivate
, andOnDeactivate
should now always be
invoked on the active instance of a component rather than the instance
created during route resolution. This previously could occur when navigating
away and back to a nested route whose parent was not reusable.
angular_test
2.0.0-alpha+7
- Maintenance release, supporting newer package versions.
5.0.0-alpha+8
angular
5.0.0-alpha+8
New features
-
Compiler can optimize field accesses to classes that are statically accessed
usingexports
. -
Compiler will now set immutable
Text
node values at component build time.
For more details see #993
Breaking changes
-
Removes the old template parser completely. The new template parser was made
the default in5.0.0-alpha+5
. -
InjectionError.enableBetterErrors
was removed, it is now the (only) option
and is always enabled at development time. We are still waiting for fixes
to the view compiler to complete this feature:
#434 -
Support for injecting services by an arbitrary object or literal is being
discontinued for compile-time injection. You'll receive a build exception;
fix by instead either providing by aType
orOpaqueToken
/MultiToken
.
Bug fixes
-
Testability now includes ComponentState updates. Due to prior use of
animationFrame callback, testbed was not able to detect stable state. -
Misspelled or otherwise erroneous annotations on classes now produce a more
understandable error message, including the element that was annotated and
the annotation that was not resolved. -
bootstrapFactory
now injects an implementation ofSlowComponentLoader
that always throws. This is to allow a migration path for common components
that still injetSlowComponentLoader
into apps that are using the new
bootstrap. -
List<Element>
andList<HtmlElement>
for@ViewChildren
and
@ContentChildren
no longer requireread: Element
, and the type is
correctly inferred the same as a single child is. -
Missing a selector for a query (such as
@ViewChild
) throws a better error.
angular_ast
0.4.4
- Added
MinimizeWhitespaceVisitor
.
angular_compiler
0.4.0-alpha+8
Breaking changes
- Removed
use_new_template_parser
flag. The old parser was removed. - Requires
source_gen >= 0.7.6
. - Removed support for parsing arbitrary objects or literal values as a
provider token fromTokenReader
. In a future version of the compiler
these arguments will be completely removed.
Bug Fixes
- Misspelled or otherwise erroneous annotations on classes now produce a more
understandable error message, including the element that was annotated and
the annotation that was not resolved. - Fix a bug where
throwFailure
hit an NPE without a stack trace.
angular_forms
2.0.0-alpha
NOTE: This used to be 1.0.1-alpha
, but has changed to be 2.0.0-alpha
due
to the fact that there are breaking changes in the previous dev releases. Future
development releases are moving to 2.x.x
, and a 1.0.1
will never be
released.
Breaking changes
AbstractControl.find
now only accepts a String. To supply a list, use
AbstractControl.findPath
instead. Also, forfind
orfindPath
,
ControlArray
index is now callingint.parse
instead of expecting a raw
number.
angular_router
2.0.0-alpha+8
Breaking changes
APP_BASE_HREF
is being renamedappBaseHref
.
angular_test
2.0.0-alpha+6
- Maintenance release, supporting newer package versions.
5.0.0-alpha+7
angular
5.0.0-alpha+7
NOTE: We now require a dev SDK of >=2.0.0-dev.28.0
.
Breaking changes
-
SafeInnerHtmlDirective
is no longer injectable. -
The following types were never intended for external use and are no longer
exported bypackage:angular/security.dart
:SafeHtmlImpl
SafeScriptImpl
SafeStyleImpl
SafeResourceUrlImpl
SafeUrlImpl
SafeValueImpl
To mark a value as safe, users should inject
DomSanitizationService
and
invoke the correspondingbypassSecurityTrust*()
method, instead of
constructing these types directly. -
Private types can't be used in template collection literals bound to an
input. This is a consequence of fixing a cast warning that is soon to be an
error caused by the code generated for change detecting collection literals
in templates. See #844 for more
information. -
OpaqueToken
andMultiToken
no longer have overriddenoperator==
and
hashCode
methods/fields. This wasn't supported, in practice, in most of
the DI systems, but any custom use of this class may have relied on this.
Bug fixes
-
The view compiler hoists
this.rootEl
as afinal
local variable to help
Dart2JS know that its type stays the same and that repeated accesses to the
class instance variable is not needed. This should help remove interceptors
and reduce code-size a bit, especially for users of@HostBinding
or
@HostListener
(#450). -
Fixed a cast warning caused by untyped code generated for change detecting
collection literals in templates. -
The view compiler is now able to tell when
exports
which are static reads
of the component class are immutable andString
type. This allows us to
optimize them when they are used in template bindings. See
#995 for more information.
angular_ast
0.4.3+1
- Maintenance release, supporting newer package versions.
angular_compiler
0.4.0-alpha+7
- Maintenance release.
angular_forms
1.0.1-alpha+7
Breaking changes
-
The following directives are no longer injectable:
NgControlStatus
RequiredValidator
MinLengthValidator
MaxLengthValidator
PatternValidator
-
Properly typed the generic parameter on subclasses of
AbstractControlDirective
. Now,NgControl.control
will return a
Control
, andControlContainer.control
will return aControlGroup
.
There may be some unnecessary casts that can now be cleaned up. -
FormBuilder
instance methodsgroup
,control
, andarray
have been
removed. ForFormBuilder.control
, just callnew Control(value, validator)
directly. ForFormBuilder.group
andFormBuilder.array
, use
the static methodsFormBuilder.controlGroup
and
FormBuilder.controlArray
, respectively.FormBuilder
is no longer
Injectable
.
angular_router
2.0.0-alpha+7
Breaking changes
-
RouterOutlet
is no longer injectable. -
Renamed
Router.stream
toRouter.onRouteActivated
.Router.stream
is now
deprecated and will be removed after next release.
Bug fixes
RouterPath.toUrl()
no longer generates an incorrect URL with an extra '/'
when a parent route has an empty path.
angular_test
2.0.0-alpha+5
- Maintenance release, supporting newer package versions.