This change moves many APIs to the angular2/core export.
This change also automatically adds FORM_BINDINGS in
the application root injector.
BREAKING CHANGE:
Many dependencies that were previously exported from specific
APIs are now exported from angular2/core. Affected exports, which
should now be included from angular2/core include:
angular2/forms
angular2/di
angular2/directives
angular2/change_detection
angular2/bootstrap (except for dart users)
angular2/render
angular2/metadata
angular2/debug
angular2/pipes
Closes#3977
Instead of working with finer grained element injectors, queries now
iterate through the views as static units of modification of the
application structure. Views already contain element injectors in the
correct depth-first preorder.
This allows us to remove children linked lists on element injectors and a
lot of book keeping that is already present at the view level.
Queries are recalculated using the afterContentChecked and
afterViewChecked hooks, only during init and after a view container has
changed.
BREAKING CHANGE:
ViewQuery no longer supports the descendants flag. It queries the whole
component view by default.
Closes#3973
BREAKING CHANGE
Previously a content binding of a component was visible to the directives in its view with the host constraint. This is not the case any more. To access that binding, remove the constraint.
When running in Dartium without using transformers (i.e. with a normal
static web server), handle relative template URLs. This works by using
mirrors to get the URL of the library where the component class is
defined.
Closes#2771Closes#3743
BREAKING CHANGE:
This change moves the http module into angular2/, so its import
path is now angular2/http instead of http/http.
Many other modules have also been moved around inside of angular2,
but the public API paths have not changed as of this commit.
Currently the transformer generates all getters and setters even when
creating pre-generated change detectors, which remove the need for them.
Generate getters and setters via the model provided by `ProtoViewDto`,
which contains enough information to allow omitting unnecessary getters
and setters from code output.
Allow generating getters, setters, and method names which are Dart
pseudo keywords.
Closes#3489
currently throwing an error
```error
Error during instantiation of LocationStrategy! (RouterLink -> Router
-> Location -> LocationStrategy).
ORIGINAL ERROR: TypeError: baseElement.attr is not a function
```
Closes#3214
Provide the ability to attach custom data onto a route and retrieve
that data as an injectable (RouteData) inside the component.
Closes#2777Closes#3541
BREAKING CHANGE (maybe)
Well as long as our customers use public API this should not be a
breaking change, but we have changed import structure as well as
internal names, so it could be breaking.
import:
angular2/annotations => angular2/metadata
Classes:
*Annotations => *Metadata
renderer.DirectiveMetadata => renderer.RendererDirectiveMetadata
renderer.ElementBinder => renderer.RendererElementBinder
impl.Directive => impl.DirectiveMetadata
impl.Component => impl.ComponentMetadata
impl.View => impl.ViewMetadata
Closes#3660
Fixes a bug in view manager util where sibling injector is not correctly
calculated.
ViewQuery no longer includes the view's initiating component injector.
Includes some refactoring of view methods and a removal of a polymorphic
map call.
Closes#3033Closes#3439
BREAKING CHANGE:
Instead of configuring pipes via a Pipes object, now you can configure them by providing the pipes property to the View decorator.
@Pipe({
name: 'double'
})
class DoublePipe {
transform(value, args) { return value * 2; }
}
@View({
template: '{{ 10 | double}}'
pipes: [DoublePipe]
})
class CustomComponent {}
Closes#3572
- Extends URLSearchParams API to include operations for combining
different URLSearchParams objects:
These new methods include:
setAll(otherParams): performs `this.set(key, values[0])` for each
key/value-list pair in `otherParams`
appendAll(otherParams): performs `this.append(key, values)` for
each key/value-list pair in `otherParams`
replaceAll(otherParams): for each key/value-list pair in
`otherParams`, replaces current set of values for `key` with
a copy of the list of values.
- RequestOptions do not merge search params automatically (because
there are multiple ways to do this). Instead, they replace any
existing `search` field if `search` is provided. Explicit merging
is required if merging is desirable.
- Some extra test coverage added.
Closes#2417Closes#3020
BREAKING CHANGE
- Pipe factories have been removed.
- PIpe names to pipe implementations are 1-to-1 instead of 1-to-*
Before:
class DateFormatter {
transform(date, args){}
}
class DateFormatterFactory {
supporst(obj) { return true; }
create(cdRef) { return new DateFormatter(); }
}
new Pipes({date: [new DateFormatterFactory()]})
After
class DateFormatter {
transform(date, args){}
}
new Pipes({date: DateFormatter})
BREAKING CHANGE:
The selector for the CSSClass directive was changed
from [class] to [ng-class]. The directive itself was
renamed from CSSClass to NgClass
Closes#3498
Formatting code requires time and memory during the build -- do not do
it unless explicitly requested via a parameter to the transformer.
Add an entry to the
[wiki](https://github.com/angular/angular/wiki/Angular-2-Dart-Transformer)
describing the added parameter.
Previously, the error messages coming out of the Dart transformer were
opaque when those errors came from the analyzer (for example, analyzer
parse errors). Log more useful errors when they are caught by the
transform code.
Previously I added parens everywhere to make this @proxy() because our typing indicated
it was a function that returned a decorator, but this breaks dart. Instead, the typing needs
to be changed.
Fixes#3494
Promise used to be typed as any, giving incorrect results. This change
fixes places that were incorrectly typed and re-exports the actual
Promise type from es6-promise.
It also fixes a series of compilation errors discovered/triggered by
this change.
BREAKING CHANGE
Previously, if an element had a property, Angular would update that property even if there was a directive placed on the same element with the same property. Now, the directive would have to explicitly update the native elmement by either using hostProperties or the renderer.
This change also makes us compliant with 1.6.0-dev compiler,
so we can do some experiments with apps that use 1.6 features
and compile against Angular.
We should probably add a travis build for 1.6 so we stay compatible
with both versions.
Introduces the injectable `TemplateCloner` that can be configured via the new token `MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN`.
Also replaces `document.adoptNode` with `document.importNode` as otherwise
custom elements are not triggered in chrome 43.
Closes#3418Closes#3433
BREAKING CHANGE:
Replace @Ancestor() with @Host() @SkipSelf()
Replace @Unbounded() wwith @SkipSelf()
Replace @Ancestor({self:true}) with @Host()
Replace @Unbounded({self:true}) with nothing
Replace new AncestorMetadata() with [new HostMetadata(), new SkipSelfMetadata()]
Replace new UnboundedMetadata() with new SkipSelfMetadata()
Replace new Ancestor({self:true}) with new HostMetadata()
LifeCycle can now be imported via angular2/angular2 or
angular2/core, so that end users can inject it without
having to use the full source path.
Closes#3395
Also inserts comment nodes before/after projected nodes so that text nodes don’t get merged when we serialize/deserialize them.
Closes#3356
First part of #3364
Move the implementation of `(de)hydrate`, `hydrated`, and
`detectChangesInRecords` into `AbstractChangeDetector`.
Add comments clarifying the contract between `AbstractChangeDetector`
and its subclasses.
Closes#3245
Move fields common to Dynamic, Jit, and Pregen change detectors into the
`AbstractChangeDetector` superclass to save on codegen size and reduce
code duplication.
Update to #3248, closes#3243
BREAKING CHANGES:
- `ShadowDomStrategy` was removed. To specify the encapsulation of a component use `@View(encapsulation: ViewEncapsulation.NONE | ViewEncapsulation.EMULATED | ViewEncapsulation.NATIVE)`
- The default encapsulation strategy is now `ViewEncapsulation.EMULATED` if a component contains styles and `ViewEncapsulation.NONE` if it does not. Before this was always `NONE`.
- `ViewLoader` now returns the template as a string and the styles as a separate array
Call new `(de)hydrateDirectives` methods from `(de)hydrate`. Add a null
implementation in `AbstractChangeDetector` and only override if
necessary for the specific change detector.
Update to #3248
Create `looseNotIdentical => !looseIdentical`, which will save a lot of
unnecessary '!' characters in generated change detectors.
Update to https://github.com/angular/angular/issues/3248
Previously, `uninitialized()` was a method, requiring a call as well as
two extra characters everywhere it was used.
Make this value a variable, saving the characters and avoiding the
method call to get its value.
This change also removes the export of `uninitialized` from
change_detect.ts, which is technically a breaking change, however
`uninitialized` is an implementation detail and nobody should be using
it in app logic. By convention, apps should not be importing from files
under `src/`.
Update to #3248.
Fixes#3001
BREAKING CHANGE:
View renderer used to take normalized CSS class names (ex. fooBar for foo-bar).
With this change a rendered implementation gets a calss name as specified in a
template, without any transformations / normalization. This change only affects
custom view renderers that should be updated accordingly.
Closes#3264
Create `NameRegistry`, responsible for understanding how names are
generated for change detector fields and variables.
Use `NameRegistry` for both JS Jit & Dart pre-generated detectors.
Making progress on #3248
Previously, the compiler would detect cycles where there were none just because of other components that were compiled in parallel. Furthermore, the way ProtoView merging was triggered could result into early exits resulting in errors when trying to instantiate ProtoViews.
Fixes#3206Closes#3211
BREAKING CHANGE
Previously it was possible to pass a custom error reporter to bootstrap, which was used only during the construction of Injector. This had limited utility, so this capability has been removed.
BREAKING CHANGES:
Dart applications and TypeScript applications meant to transpile to Dart must now
import `package:angular2/bootstrap.dart` instead of `package:angular2/angular2.dart`
in their bootstrap code. `package:angular2/angular2.dart` no longer export the
bootstrap function. The transformer rewrites imports of `bootstrap.dart` and calls
to `bootstrap` to `bootstrap_static.dart` and `bootstrapStatic` respectively.
When a `Directive` implements a lifecycle interface (e.g. `OnChange` or
`OnInit`), populate its `lifecycle` property if not already populated).
Closes#3181
BREAKING CHANGE
The @Parent annotation has been removed. Use @Ancestor instead.
@Parent was used to enforce a particular DOM structure (e.g., a pane component is a direct child of the tabs component).
DI is not the right mechanism to do it. We should enforce it using schema instead.
The Angular 2 render compiler can get out of sync between its transformer
execution and its runtime execution, leading to incorrect change detectors with
out-of-order property values. Stable sorting solves this problem (temporarily).
Angular fetches template HTML files outside of the browser's normal parsing flow. As a result, URLs in template files are interpreted relative to the root application, when the components defined by the template files are inserted into the DOM. This change enables a template author to prefix URLs with the string $baseUrl, which will be replaced with the relative base path of the template file.
So for an example template loaded from /component/foo/template.html:
<img src="$baseUrl/logo.png" />
becomes:
<img src="/component/foo/logo.png" />
Addresses #2384.
Implement deferred libraries to work with dependency injection and other
angular codegen. This is done by not initializing the library in the parent
ng_deps file when it is declared as deferred, rewriting the import and,
chaining a future that initializes the library in any files that are using
deferred libraries which need angular codegen.
BREAKING CHANGES:
`ViewManager.createView` / `ViewContainerRef.create` have been split into 2 methods:
- `createHostView` which takes dynamically created bindings
- `createEmbeddedView` which takes the newly introduced `TemplateRef`
The new type `TemplateRef` is the combination of a `ProtoViewRef` and and `ElementRef`
from the same place. Use `TemplateRef` when working with embedded views in
`ng-if`, `ng-for`, ... instead of `ProtoViewRef`.
Also, `ProtoViewRef` is no more injectable, but `TemplateRef` is.
First part of #1989 to clean up manual content projection.
Closes#3114
Remove reflector parameter from initReflector method to simplify ng_deps for reflection
initialization. It wasn't used and was added for testability, but wasn't used. This
keeps the interface simplier.
In Dart, '$' indicates the beginning of an interpolation.
- Escapes '$' in strings when generating change detector classes.
- Adds a unit test to cover this case.
Closes#2529
BREAKING CHANGES:
- shadow dom emulation no longer
supports the `<content>` tag. Use the new `<ng-content>` instead
(works with all shadow dom strategies).
- removed `DomRenderer.setViewRootNodes` and `AppViewManager.getComponentView`
-> use `DomRenderer.getNativeElementSync(elementRef)` and change shadow dom directly
- the `Renderer` interface has changed:
* `createView` now also has to support sub views
* the notion of a container has been removed. Instead, the renderer has
to implement methods to attach views next to elements or other views.
* a RenderView now contains multiple RenderFragments. Fragments
are used to move DOM nodes around.
Internal changes / design changes:
- Introduce notion of view fragments on render side
- DomProtoViews and DomViews on render side are merged,
AppProtoViews are not merged, AppViews are partially merged
(they share arrays with the other merged AppViews but we keep
individual AppView instances for now).
- DomProtoViews always have a `<template>` element as root
* needed for storing subviews
* we have less chunks of DOM to clone now
- remove fake ElementBinder / Bound element for root text bindings
and model them explicitly. This removes a lot of special cases we had!
- AppView shares data with nested component views
- some methods in AppViewManager (create, hydrate, dehydrate) are iterative now
* now possible as we have all child AppViews / ElementRefs already in an array!
By binding the token `DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES` provided by
the dom_renderer module to `true` in the root injector (i.e. bootstrap()),
all elements whose properties are set by angular will be reflected as
attributes with the prefix "ng-reflect-".
Fixes#2910
This fixes several minor indentation issues (instanceof precendence,
type declaration specificity, template string length calculation).
This should also fix some flip-flop situations with template strings.
BREAKING CHANGE:
This change renames all instances of PipeRegistry to Pipes.
As part of this change, the former "defaultPipes" export is
now a Pipes instance, instead of a map. The map that was previously
called "defaultPipes" no longer exists, but may be accessed via
defaultPipes.config.
This is its own commit so that tools have an easier time of preserving
history of the file, by keeping the diff between pipes.ts and
pipe_registry.ts minimal.
Also moved pipe_registry_spec.ts