Introduces `ref-` to give a name to an element or a directive (also works for `<template>` elements), and `let-` to introduce an input variable for a `<template>` element.
BREAKING CHANGE:
- `#...` now always means `ref-`.
- `<template #abc>` now defines a reference to the TemplateRef, instead of an input variable used inside of the template.
- `#...` inside of a *ngIf, … directives is deprecated.
Use `let …` instead.
- `var-...` is deprecated. Replace with `let-...` for `<template>` elements and `ref-` for non `<template>` elements.
Closes#7158Closes#8264
This changes Angular so that it can be used without reflection (assuming a codegen for injectors).
BREAKIKNG CHANGE:
- Drops `APP_COMPONENT` provider. Instead, inject
`ApplicationRef` and read its `componentTypes` property.
- long form bootstrap has changed into the following:
```
var platform = createPlatform(ReflectiveInjector.resolveAndCreate(BROWSER_PROVIDERS));
var appInjector =
ReflectiveInjector.resolveAndCreate([BROWSER_APP_PROVIDERS, appProviders], platform.injector);
coreLoadAndBootstrap(appInjector, MyApp);
```
Each compile template now exposes a `<CompName>NgFactory` variable
with an instance of a `ComponentFactory`.
Calling `ComponentFactory.create` returns a `ComponentRef` that can
be used directly.
BREAKING CHANGE:
- `Compiler` is renamed to `ComponentResolver`,
`Compiler.compileInHost` has been renamed to `ComponentResolver.resolveComponent`.
- `ComponentRef.dispose` is renamed to `ComponentRef.destroy`
- `ViewContainerRef.createHostView` is renamed to `ViewContainerRef.createComponent`
- `ComponentFixture_` has been removed, the class `ComponentFixture`
can now be created directly as it is no more using private APIs.
BREAKING CHANGE:
- Renderer:
* renderComponent method is removed form `Renderer`, only present on `RootRenderer`
* Renderer.setDebugInfo is removed. Renderer.createElement / createText / createTemplateAnchor
now take the DebugInfo directly.
- Query semantics:
* Queries don't work with dynamically loaded components.
* e.g. for router-outlet: loaded components can't be queries via @ViewQuery,
but router-outlet emits an event `activate` now that emits the activated component
- Exception classes and the context inside changed (renamed fields)
- DebugElement.attributes is an Object and not a Map in JS any more
- ChangeDetectorGenConfig was renamed into CompilerConfig
- AppViewManager.createEmbeddedViewInContainer / AppViewManager.createHostViewInContainer
are removed, use the methods in ViewContainerRef instead
- Change detection order changed:
* 1. dirty check component inputs
* 2. dirty check content children
* 3. update render nodes
Closes#6301Closes#6567
Replace direct uses of `print` in the transformer with explicit uses of
stderr.
Add a few @override annotations for clarification of other `print`
implementations.
Clarify error message on incorrect custom_annotations value.
Closes#7855
Pt 4 of migrating from package:guinness + package:unittest =>
package:test.
This PR migrates DeferredRewriter & DirectiveMetadataLinker unit tests.
Closes#7703
Update the Angular 2 transformer to recognize
`package:angular2/platform/browser.dart` as the library which exports
the `bootstrap` function.
Update playground, examples, benchmarks, & tests to import bootstrap from
platform/browser.
Closes#7647
Pt 3 of migrating from package:guinness + package:unittest => package:test.
This PR migrates DirectiveProcessor & InlinerForTest unit tests.
Closes#7475
These were previously not being run.
Bring them up to modern usage, move them to package:test, and include
them in transform.server.spec.dart.
Closes#7463
Create transformers that allow specifying transformer actions on
specific libraries.
* angular2/transform/codegen: Generates all necessary code.
* angular2/transform/reflection_rewriter: Replaces `bootstrap` calls in
application entry points to remove transitive dart:mirrors import,
resulting in smaller code size & faster execution.
* angular2/transform/deferred_rewriter: Rewrites deferred imports and
`loadLibrary` calls to initialize Angular2 and preserve deferred
operation.
Proper configuration of these three transformers can replace the single
angular2 transformer, resulting in significant performance gains for
builds of large angular2 apps.
Update angular2 itself to declare the codegen transformer, since it has
neither deferred imports nor application entry points.
Remove the undocumented & unused quick_transformer.
BREAKING CHANGE:
`OnPushObserve` was an experimental
feature for Dart and had
conceptual performance problems,
as setting up observables is slow.
Use `OnPush` instead.
Our transformer unit tests currently use package:guinness, which uses
package:unittest under the covers. package:unittest has been updated and
renamed package:test, so for simplicity migrate test to use package:test
syntax.
Issue raised in PR #6745.
Previously, the transformer name conversion functions could return the
input string on unexpected input, which is almost certainly an error.
`throw` in this case instead, so we know early that something has likely
gone wrong.
Closes#6753
Previously, every .dart file in a package was processed to ensure proper
initialization of deferred loaded libraries.
Update the transformer to avoid processing libraries which we know do
not import any deferred libraries.
Closes#6745
Handle some cases which would previously result in broken code.
- Importing bootstrap.dart deferred
- Using combinators when importing bootstrap.dart
- Importing bootstrap.dart with a prefix
Closes#6749
Previously, we generated the code to initialize the reflector into the
<file>.ng_deps.dart and the compiled template and change detector code
into <file>.template.dart.
Update the transformer to generate all code into <file>.template.dart to
avoid the additional HTTP requests necessary when debugging
applications in Dartium.
BEFORE:
The following would throw in the dev mode because `f` would return a new array when called by checkNoChanges.
@Component({
template: `
{{f()}}
`
})
class A {
f() { return [1]; }
}
AFTER:
The checkNoChanges function compares only primitives types for equality, and deeply compares iterables. Other objects cannot cause checkNoChanges to throw. This means that the dev mode would never fail given a legal program, but may allow some illegal programs.