4.0.0
We are now named package:angular instead of package:angular2. As such
you cannot pub upgrade from angular2 3.x -> angular2 4.x, and you need to
manually update your dependencies instead:
dependencies:
angular: ^4.0.0AngularDart will start tracking the upcoming Dart 2.0 alpha SDK, and as such,
4.0.0 will be the last stable release that fully supports Dart 1.24.0. We may
release small patches if needed, but otherwise the plan is to release 4.0.0 and
then immediately start working on 5.0.0-alpha, which uses the new Dart SDK.
Breaking changes
-
@Pipe-annotated classes are no longer considered@Injectable, in that
they aren't usable within aReflectiveInjector. You can get this behavior
back by adding the@Injectable()annotation to the@Pipe-annotated
class. Similar changes are in progress for@Componentand@Directive. -
PLATFORM_{PIPES|DIRECTIVES|PROVIDERS}, which was only supported in an
older version of the compiler, was removed. All of these must be manually
included in lists in an@Directiveor@Componentannotation. -
Removed
formDirectivesfromCOMMON_DIRECTIVESlist; replace
COMMON_DIRECTIVESwith[CORE_DIRECTIVES, formDirectives]for components
that use forms directives. -
Forms API has been moved to a new package,
angular_forms, which is going
to be versioned and maintained alongside the core framework. This should
allow better segmentation of code and easier contributions. -
The router package is now being published separate as
package:angular_router(not throughpackage:angular/router.dart). In the
near future it will be updated to a more Dart idiomatic "2.0" router, but
for now it is an exact replica of the previous router. -
Removed
@{Component|Directive}#queries. This is replable using the same
member-level annotation (i.e.@{Content|View}Child{ren}). -
DynamicComponentLoaderwas renamedSlowComponentLoaderto encourage
users to preferComponentLoader. Additionally, arguments
projectableNodes:andonDestroy:callbacks were removed - they were
mostly unused, and confusing since they were undocumented. -
Removed
angular/platform/browser_static.dart; replace imports with
angular/angular.dart. -
Removed
angular/platform/common_dom.dart; replace imports with
angular/angular.dart. -
Removed
angular/testing.dart; Useangular_testpackage instead. -
Removed
angular/platform/testing.dart. -
Removed
platform/testing/browser_static.dart. -
Removed
MockNgZone. -
Removed
ViewEncapsulation.native, which is no longer supported. -
Renamed
FORM_DIRECTIVEStoformDirectives. -
Removed
angular/common.dart; replace imports withangular/angular.dart. -
Removed
angular/compiler.dart; compiler should only be invoked via the
transformers or viapkg:builddirectly usingangular/source_gen.dart. -
Deprecated
@View()annotation was completely removed. -
Deprecated second parameter to
ExceptionHandlerwas completely removed. -
Removed the runtime (
dart:mirrors-based) interpreter. It is now required
to always use the AngularDart transformer to pre-compile the code, even
during development time in Dartium.package:angular2/reflection.dartwas
also removed. -
The
bootstrapfunction now always throws a runtime exception, and both it
andbootstrapStaticare accessible viaangular.dartinstead of
platform/browser.dartandplatform/browser_static.dart
#357. -
Returning
falsefrom an event handler will no longer cancel the event. See
#387 for details. -
Removed
QueryandViewQuery. Please useContentChild/ContentChildren
andViewChild/ViewChildrenin their place instead. -
Removed the
use_analyzerflag for the transformer. This is alwaystrue.
#404. -
Removed all other unused or unsupported flags from the transformer. There is
now a singleCompilerFlagsclass that is universally supported for all
build systems. -
Removed a number of classes that were never intended to be public.
-
Removed the second parameter to
ExceptionHandler, which was a no-op
anyway. -
Removed
outputsfield fromDirective. Outputs now must be declared using
inlineOutputannotations.
New features
-
Added support for functional directives: lightweight, stateless directives
that apply a one-time transformation.-
One is defined by annotating a public, top-level function with
@Directive(). -
The function parameters specify its dependencies, similar to the
constructor of a regular directive. -
Only the
selectorandprovidersparameters of the@Directive()
annotation are permitted, because the other parameters are stateful. -
The function return type must be
void.
-
@Directive(selector: '[autoId]')
void autoIdDirective(Element element, IdGenerator generator) {
element.id = generator.next();
}- Added
visibilityproperty toDirective. Directives and components that
don't need to be injected can setvisibility: Visibility.nonein their
annotation. This prevents the compiler from generating code necessary to
support injection, making the directive or component non-injectable and
reducing the size of your application.
// This component can't be injected by other directives or components.
@Component(selector: 'my-component', visibility: Visibility.none)
class MyComponent { ... }- Added
ComponentLoader, a high-level imperative API for creating components
at runtime. It uses internal code-paths that already existed, and is much
more future proof.ComponentLoaderis usable within a@Directive(), an
@Component(), and injectable services.
// An `ExampleComponent`s generated code, including a `ComponentFactory`.
import 'example.template.dart' as ng;
class AdBannerComponent implements AfterViewInit {
final ComponentLoader _loader;
AdBannerComponent(this._loader);
@override
ngAfterViewInit() {
final component = _loader.loadDetached(ng.ExampleComponentNgFactory);
// Do something with this reference.
}
}-
You can now directly inject
dart:html'sElementorHtmlElementinstead
ofElementRef, which is "soft deprecated" (will be deprecated and removed
in a future release). -
findContainerhas now been exposed from NgForm allowing easier creation of
custom form implementations. -
setUpControlhas been exposed from the forms API to allow forms to setup
their controls easier. -
Inheritance for both component and directive metadata is now complete! Any
field or method-level annotations (@Input,@Output,
@ViewChild|Children,@ContentChild|Children) are now inherited through
super types (extends,implements,with)
#231:
class BaseComponent {
@Input()
String name;
}
// Also has an input called "name" now!
@Component(selector: 'comp')
class ConcreteComponent extends BaseComponent {}- Inputs that are of type
boolnow receive a default value oftrueinstead
of a value ofnullor an empty string. This allows a much more
HTML-friendly syntax for your components:
<!-- All of these set a value of disabled=true -->
<fancy-button disabled></fancy-button>
<fancy-button [disabled]></fancy-button>
<fancy-button [disabled]="true"></fancy-button>
<!-- Value of disabled=false -->
<fancy-button [disabled]="false"></fancy-button>@Component()
class FancyButton {
@Input()
bool disabled = false;
}- Added
exports: [ ... ]to@Component, which allows the limited use of
top-level fields and static methods/fields in a template without making an
alias getter in your class. Implements
#374.
import 'dart:math' show max;
@Component(
selector: 'comp',
exports: const [
max,
],
// Should write '20'
template: '{{max(20, 10)}}',
)
class Comp {}-
Limitations:
- Only top-level fields that are
const(notfinal) can be exported.
- Only top-level fields that are
-
Added
@deferredas the first "compile-time" directive (it has no specific
runtime code nor is it listed in adirectives: [ ... ]list. Implements
#406.
import 'package:angular2/angular2.dart';
import 'expensive_comp.dart' show ExpensiveComp;
@Component(
selector: 'my-comp',
directives: const [ExpensiveComp],
template: r'''
<expensive-comp @deferred></expensive-comp>
''',
)
class MyComp {}-
Added preliminary support for component inheritance. Components now inherit
inputs, outputs, host bindings, host listeners, queries, and view queries
from all supertypes. -
We use a new open sourcing tool called "CopyBara" that greatly
simplifies both releasing and taking open source contributions. We are able
to release to github more often, and accept PRs much more easily. You can
view our bleedinggithub-syncbranch for what has yet to be
merged intomaster. -
We no longer emit
ng_*.jsonfiles as part of the compile process
#276. -
Attribute selectors (
<ng-content select="custom-action[group='1']">) is
now supported #237. -
Lifecycle interfaces no longer need to be "re-implemented" on classes in
order for the compiler to pick them up - we now respect the dependency chain
#19. -
Provider(useValue: ...)now accepts "complex const data structures", with
the caveat that your data structure must not be invoking a private
constructor #10.
Deprecations
- Support for shadow piercing combinators
/deep/and>>>to prevent style
encapsulation is now deprecated./deep/is already deprecated and will be
removed in Chrome 60. Its alias>>>is limited to the
static profile of selectors, meaning it's not supported in
style sheets. Continued use of these combinators puts Angular at risk of
incompatibility with common CSS tooling.::ng-deepis a drop-in
replacement, intended to provide the same functionality as/deep/and
>>>, without the need to use deprecated or unsupported CSS syntax
#454.
Bug fixes
-
Compiler now warns when annotations are added to private classes or
functions. -
Compiler now warns when injecting into a field that is non-existent.
-
Fixed a long-standing bug on
ngSwitchbehavior in Dartium. -
Fixed a bug in
@deferredwhen nested views has DI bindings. Fixes
#578. -
The transformer now fails if any unsupported arguments are passed in.
-
Fixed a bug where
@deferreddid not work nested inside of<template>:
<template [ngIf]="someCondition">
<expensive-comp @deferred></expensive-comp>
</template>-
ngFormnow allowsonSubmitto be called with anullvalue. -
Using
inputs|outputsin the@Componentannotation to rename an existing
@Input()or@Output()now logs and fails the build during compilation. -
Symbol collisions with
dart:htmlno longer cause a runtime exception, all
framework use ofdart:htmlis now scoped behind a prefixed import. -
Properly annotate methods in generated
.template.dartcode with
@override. -
Updated the documentation for
OnInitandOnDestroyto mention more
specifics about the contract and document "crash detection" cases where they
may be called more than once. -
*ngIfnow properly checks that inputs do not change during change
detection #453. -
Properly typed
TrackByFnas anintnot anum
#431. -
Import aliases are supported by the compiler
#245.
Performance
-
Various small reductions to the size of generated code and the runtime.
-
Directives now generate their own change detector class (behind the scenes)
instead of the code being re-created into every component that uses a
directive. -
Remove redundant calls to
dbg(...)in dev-mode. This reduces the amount of
work done and speeds up developer runtimes, such as those using the
DartDevCompiler
(DDC). -
Some change detection code that was duplicated across all generated
templates were moved internally to a newAppView#detectHostChangesmethod. -
Introduced a new
AppViewDatastructure in the generated code that
decreases code size ~2% or more in some applications due to better code
re-use and emit in dart2js. -
We no longer change detect literals and simple
finalproperty reads. -
Some of the enums used to manage change detection state have been simplified
tointin order to reduce the cost in the generated code.
angular_router
1.0.2
- Support for angular 4.0.0.
angular_forms
1.0.0
- Support for angular 4.0.0.
angular_test
1.0.0
Breaking Changes & Deprecations
-
Throws in bootstrapping if the root component does not use default change
detection. AngularDart does not supportOnPushor other change detection
strategies on the root component. -
Pub serve now defaults to a random unused port (instead of
8080) and
--portis deprecated. Going forward the supported way to supply this
argument is via--serve-arg:
$ pub run angular_test --serve-arg=port=1234- Option
--run-test-flag(-t) is now deprecated, and no longer has a
default value ofaot. Tags are still highly encouraged in order to have
faster compilation times! Use--test-arginstead:
$ pub run angular_test --test-arg=--tags=aot- Option
--platform(-p) is now Deprecated, and no longer has a
default value ofcontent-shell, which was not always installed on host
machines. Instead use--test-arg:
$ pub run angular_test --test-arg=--platform=content-shell-
Option
--name(-n) and--simple-name(-N) are also deprecated. Use
--test-arg=--name=and--test-arg=--simple-name=instead. -
Changes to
compatibility.dartmight not be considered in future semver
updates, and it highly suggested you don't use these APIs for any new
code. -
Change
NgTestFixture.updateto have a single optional parameter
Features
-
Add assertOnlyInstance to fixture to remove some boilerplate around testing
the state of a instance. Only use to test state, not to update it. -
Added
--serve-argand--test-arg, which both support multiple arguments
in order to have better long-term support for proxying to bothpub serve
andpub run testwithout frequent changes to this package. For example to
use the [DartDevCompiler (dartdevc)]:
$ pub run angular_test --serve-arg=web-compiler=dartdevc- Add support for setting a custom
PageLoaderfactory:
testBed = testBed.setPageLoader(
(element) => new CustomPageLoader(...),
);- Add support for
queryandqueryAlltoNgTestFixture. This works
similar to theupdatecommand, but is called back with either a single or
multiple child component instances to interact with or run expectations
against:
// Assert we have 3 instances of <child>.
await fixture.queryAll(
(el) => el.componentInstance is ChildComponent,
(children) {
expect(children, hasLength(3));
},
);- Add built-in support for
package:pageloader:
final fixture = await new NgTestBed<TestComponent>().create();
final pageObject = await fixture.getPageObject/*<ClickCounterPO>*/(
ClickCounterPO,
);
expect(await pageObject.button.visibleText, 'Click count: 0');
await pageObject.button.click();
expect(await pageObject.button.visibleText, 'Click count: 1');Fixes
-
Workaround for
pub {serve|build}hanging onangular_testas a
dependency. -
Fixes a bug where the root was not removed from the DOM after disposed.
-
Added a missing dependency on
package:func. -
Properly fix support for windows by using
pub.bat. -
Replace all uses of generic comment with proper syntax.
-
Fixed a bug where
activeTestwas never set (and therefore disposed). -
Fixed a bug where
pub, notpub.bat, is run in windows. -
Update
pubspec.yamlso it properly lists AngularDart3.0.0-alpha -
Fix the executable so
pub run angular_testcan be used -
Fix a serious generic type error when
NgTestBedis forked -
Fix a generic type error
-
Added
compatibility.dart, a temporary API to some users migrate