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.0
AngularDart 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 a ReflectiveInjector
. You can get this behavior
back by adding the @Injectable()
annotation to the @Pipe
-annotated
class. Similar changes are in progress for @Component
and @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 @Directive
or @Component
annotation.
-
Removed formDirectives
from COMMON_DIRECTIVES
list; replace
COMMON_DIRECTIVES
with [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 through package: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}
).
-
DynamicComponentLoader
was renamed SlowComponentLoader
to encourage
users to prefer ComponentLoader
. Additionally, arguments
projectableNodes:
and onDestroy:
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
; Use angular_test
package instead.
-
Removed angular/platform/testing.dart
.
-
Removed platform/testing/browser_static.dart
.
-
Removed MockNgZone
.
-
Removed ViewEncapsulation.native
, which is no longer supported.
-
Renamed FORM_DIRECTIVES
to formDirectives
.
-
Removed angular/common.dart
; replace imports with angular/angular.dart
.
-
Removed angular/compiler.dart
; compiler should only be invoked via the
transformers or via pkg:build
directly using angular/source_gen.dart
.
-
Deprecated @View()
annotation was completely removed.
-
Deprecated second parameter to ExceptionHandler
was 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.dart
was
also removed.
-
The bootstrap
function now always throws a runtime exception, and both it
and bootstrapStatic
are accessible via angular.dart
instead of
platform/browser.dart
and platform/browser_static.dart
#357.
-
Returning false
from an event handler will no longer cancel the event. See
#387 for details.
-
Removed Query
and ViewQuery
. Please use ContentChild
/ContentChildren
and ViewChild
/ViewChildren
in their place instead.
-
Removed the use_analyzer
flag for the transformer. This is always true
.
#404.
-
Removed all other unused or unsupported flags from the transformer. There is
now a single CompilerFlags
class 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 outputs
field from Directive
. Outputs now must be declared using
inline Output
annotations.
New features
@Directive(selector: '[autoId]')
void autoIdDirective(Element element, IdGenerator generator) {
element.id = generator.next();
}
- Added
visibility
property to Directive
. Directives and components that
don't need to be injected can set visibility: Visibility.none
in 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. ComponentLoader
is 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
's Element
or HtmlElement
instead
of ElementRef
, which is "soft deprecated" (will be deprecated and removed
in a future release).
-
findContainer
has now been exposed from NgForm allowing easier creation of
custom form implementations.
-
setUpControl
has 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
bool
now receive a default value of true
instead
of a value of null
or 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 {}
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 bleeding github-sync
branch for what has yet to be
merged into master
.
-
We no longer emit ng_*.json
files 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-deep
is 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 ngSwitch
behavior in Dartium.
-
Fixed a bug in @deferred
when nested views has DI bindings. Fixes
#578.
-
The transformer now fails if any unsupported arguments are passed in.
-
Fixed a bug where @deferred
did not work nested inside of <template>
:
<template [ngIf]="someCondition">
<expensive-comp @deferred></expensive-comp>
</template>
-
ngForm
now allows onSubmit
to be called with a null
value.
-
Using inputs|outputs
in the @Component
annotation to rename an existing
@Input()
or @Output()
now logs and fails the build during compilation.
-
Symbol collisions with dart:html
no longer cause a runtime exception, all
framework use of dart:html
is now scoped behind a prefixed import.
-
Properly annotate methods in generated .template.dart
code with
@override
.
-
Updated the documentation for OnInit
and OnDestroy
to mention more
specifics about the contract and document "crash detection" cases where they
may be called more than once.
-
*ngIf
now properly checks that inputs do not change during change
detection #453.
-
Properly typed TrackByFn
as an int
not a num
#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 new AppView#detectHostChanges
method.
-
Introduced a new AppViewData
structure 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 final
property reads.
-
Some of the enums used to manage change detection state have been simplified
to int
in 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 support OnPush
or other change detection
strategies on the root component.
-
Pub serve now defaults to a random unused port (instead of 8080
) and
--port
is 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 of aot
. Tags are still highly encouraged in order to have
faster compilation times! Use --test-arg
instead:
$ pub run angular_test --test-arg=--tags=aot
- Option
--platform
(-p
) is now Deprecated, and no longer has a
default value of content-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.dart
might not be considered in future semver
updates, and it highly suggested you don't use these APIs for any new
code.
-
Change NgTestFixture.update
to 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-arg
and --test-arg
, which both support multiple arguments
in order to have better long-term support for proxying to both pub serve
and pub run test
without 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
PageLoader
factory:
testBed = testBed.setPageLoader(
(element) => new CustomPageLoader(...),
);
- Add support for
query
and queryAll
to NgTestFixture
. This works
similar to the update
command, 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 on angular_test
as 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 activeTest
was never set (and therefore disposed).
-
Fixed a bug where pub
, not pub.bat
, is run in windows.
-
Update pubspec.yaml
so it properly lists AngularDart 3.0.0-alpha
-
Fix the executable so pub run angular_test
can be used
-
Fix a serious generic type error when NgTestBed
is forked
-
Fix a generic type error
-
Added compatibility.dart
, a temporary API to some users migrate
Source code(tar.gz)
Source code(zip)