refactor(router): use ApplicationRef to provide the first bootstrapped component as ROUTER_PRIMARY_COMPONENT automatically.
This removes the routerBindings function as it is no longer necessary. ROUTER_BINDINGS will automatically pick the first bootstrapped component to satisfy ROUTER_PRIMARY_COMPONENT. BREAKING CHANGE: Before: bootstrap(MyComponent, [routerBindings(myComponent)]); After: bootstrap(MyComponent, [ROUTER_BINDINGS]); Closes #4643
This commit is contained in:
@@ -90,6 +90,7 @@ var NG_API = [
|
||||
'ApplicationRef:js',
|
||||
'ApplicationRef.injector:js',
|
||||
'ApplicationRef.zone:js',
|
||||
'ApplicationRef.componentTypes:js',
|
||||
/*
|
||||
Abstract methods
|
||||
'ApplicationRef.bootstrap()',
|
||||
|
||||
@@ -20,7 +20,6 @@ import {Type} from 'angular2/src/core/facade/lang';
|
||||
|
||||
import {
|
||||
ROUTER_BINDINGS,
|
||||
ROUTER_PRIMARY_COMPONENT,
|
||||
Router,
|
||||
RouteConfig,
|
||||
APP_BASE_HREF,
|
||||
@@ -57,8 +56,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should bootstrap an app with a hierarchy', inject([AsyncTestCompleter], (async) => {
|
||||
bootstrap(HierarchyAppCmp,
|
||||
[bind(ROUTER_PRIMARY_COMPONENT).toValue(HierarchyAppCmp), testBindings])
|
||||
bootstrap(HierarchyAppCmp, testBindings)
|
||||
.then((applicationRef) => {
|
||||
var router = applicationRef.hostComponent.router;
|
||||
router.subscribe((_) => {
|
||||
@@ -72,8 +70,7 @@ export function main() {
|
||||
|
||||
|
||||
it('should work in an app with redirects', inject([AsyncTestCompleter], (async) => {
|
||||
bootstrap(RedirectAppCmp,
|
||||
[bind(ROUTER_PRIMARY_COMPONENT).toValue(RedirectAppCmp), testBindings])
|
||||
bootstrap(RedirectAppCmp, testBindings)
|
||||
.then((applicationRef) => {
|
||||
var router = applicationRef.hostComponent.router;
|
||||
router.subscribe((_) => {
|
||||
@@ -87,7 +84,7 @@ export function main() {
|
||||
|
||||
|
||||
it('should work in an app with async components', inject([AsyncTestCompleter], (async) => {
|
||||
bootstrap(AsyncAppCmp, [bind(ROUTER_PRIMARY_COMPONENT).toValue(AsyncAppCmp), testBindings])
|
||||
bootstrap(AsyncAppCmp, testBindings)
|
||||
.then((applicationRef) => {
|
||||
var router = applicationRef.hostComponent.router;
|
||||
router.subscribe((_) => {
|
||||
@@ -102,8 +99,7 @@ export function main() {
|
||||
|
||||
it('should work in an app with async components defined with "loader"',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
bootstrap(ConciseAsyncAppCmp,
|
||||
[bind(ROUTER_PRIMARY_COMPONENT).toValue(AsyncAppCmp), testBindings])
|
||||
bootstrap(ConciseAsyncAppCmp, testBindings)
|
||||
.then((applicationRef) => {
|
||||
var router = applicationRef.hostComponent.router;
|
||||
router.subscribe((_) => {
|
||||
@@ -118,9 +114,7 @@ export function main() {
|
||||
|
||||
it('should work in an app with a constructor component',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
bootstrap(
|
||||
ExplicitConstructorAppCmp,
|
||||
[bind(ROUTER_PRIMARY_COMPONENT).toValue(ExplicitConstructorAppCmp), testBindings])
|
||||
bootstrap(ExplicitConstructorAppCmp, testBindings)
|
||||
.then((applicationRef) => {
|
||||
var router = applicationRef.hostComponent.router;
|
||||
router.subscribe((_) => {
|
||||
@@ -136,8 +130,7 @@ export function main() {
|
||||
inject(
|
||||
[AsyncTestCompleter],
|
||||
(async) => {
|
||||
bootstrap(WrongConfigCmp,
|
||||
[bind(ROUTER_PRIMARY_COMPONENT).toValue(WrongConfigCmp), testBindings])
|
||||
bootstrap(WrongConfigCmp, testBindings)
|
||||
.catch((e) => {
|
||||
expect(e.originalException)
|
||||
.toContainError(
|
||||
@@ -150,9 +143,7 @@ export function main() {
|
||||
inject(
|
||||
[AsyncTestCompleter],
|
||||
(async) => {
|
||||
bootstrap(
|
||||
WrongComponentTypeCmp,
|
||||
[bind(ROUTER_PRIMARY_COMPONENT).toValue(WrongComponentTypeCmp), testBindings])
|
||||
bootstrap(WrongComponentTypeCmp, testBindings)
|
||||
.catch((e) => {
|
||||
expect(e.originalException)
|
||||
.toContainError(
|
||||
@@ -165,8 +156,7 @@ export function main() {
|
||||
inject(
|
||||
[AsyncTestCompleter],
|
||||
(async) => {
|
||||
bootstrap(BadAliasCmp,
|
||||
[bind(ROUTER_PRIMARY_COMPONENT).toValue(BadAliasCmp), testBindings])
|
||||
bootstrap(BadAliasCmp, testBindings)
|
||||
.catch((e) => {
|
||||
expect(e.originalException)
|
||||
.toContainError(
|
||||
|
||||
Reference in New Issue
Block a user