2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-06-08 19:38:52 -04:00
|
|
|
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit,} from '@angular/core/testing/testing_internal';
|
2015-07-13 19:12:48 -04:00
|
|
|
|
2016-06-10 13:21:53 -04:00
|
|
|
import {bootstrap} from '@angular/platform-browser-dynamic';
|
2016-04-28 20:50:03 -04:00
|
|
|
import {APP_BASE_HREF, LocationStrategy} from '@angular/common';
|
|
|
|
import {Component, Directive} from '@angular/core/src/metadata';
|
|
|
|
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
|
|
|
import {Console} from '@angular/core/src/console';
|
feat(testing): add implicit test module
Every test now has an implicit module. It can be configured via `configureModule` (from @angular/core/testing)
to add providers, directives, pipes, ...
The compiler now has to be configured separately via `configureCompiler` (from @angular/core/testing)
to add providers or define whether to use jit.
BREAKING CHANGE:
- Application providers can no longer inject compiler internals (i.e. everything
from `@angular/compiler). Inject `Compiler` instead. This reflects the
changes to `bootstrap` for module support (3f55aa609f60f130f1d69188ed057214b1267cb3).
- Compiler providers can no longer be added via `addProviders` / `withProviders`.
Use the new method `configureCompiler` instead.
- Platform directives / pipes need to be provided via
`configureModule` and can no longer be provided via the
`PLATFORM_PIPES` / `PLATFORM_DIRECTIVES` tokens.
- `setBaseTestProviders()` was renamed into `initTestEnvironment` and
now takes a `PlatformRef` and a factory for a
`Compiler`.
- E.g. for the browser platform:
BEFORE:
```
import {setBaseTestProviders} from ‘@angular/core/testing’;
import {TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS} from ‘@angular/platform-browser-dynamic/testing’;
setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
```
AFTER:
```
import {setBaseTestProviders} from ‘@angular/core/testing’;
import {browserTestCompiler, browserDynamicTestPlatform,
BrowserDynamicTestModule} from ‘@angular/platform-browser-dynamic/testing’;
initTestEnvironment(
browserTestCompiler,
browserDynamicTestPlatform(),
BrowserDynamicTestModule);
```
- E.g. for the server platform:
BEFORE:
```
import {setBaseTestProviders} from ‘@angular/core/testing’;
import {TEST_SERVER_PLATFORM_PROVIDERS,
TEST_SERVER_APPLICATION_PROVIDERS} from ‘@angular/platform-server/testing/server’;
setBaseTestProviders(TEST_SERVER_PLATFORM_PROVIDERS,
TEST_SERVER_APPLICATION_PROVIDERS);
```
AFTER:
```
import {setBaseTestProviders} from ‘@angular/core/testing’;
import {serverTestCompiler, serverTestPlatform,
ServerTestModule} from ‘@angular/platform-browser-dynamic/testing’;
initTestEnvironment(
serverTestCompiler,
serverTestPlatform(),
ServerTestModule);
```
Related to #9726
Closes #9846
2016-07-04 12:37:30 -04:00
|
|
|
import {provide, disposePlatform} from '@angular/core';
|
2016-04-28 20:50:03 -04:00
|
|
|
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
|
|
|
|
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
2016-05-02 13:36:58 -04:00
|
|
|
import {ROUTER_PROVIDERS, Router, RouteConfig, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
|
2016-04-28 20:50:03 -04:00
|
|
|
import {ExceptionHandler} from '@angular/core';
|
2016-06-24 15:41:57 -04:00
|
|
|
import {MockLocationStrategy} from '@angular/common/testing/mock_location_strategy';
|
2015-07-13 19:12:48 -04:00
|
|
|
|
2015-08-07 14:41:38 -04:00
|
|
|
class _ArrayLogger {
|
|
|
|
res: any[] = [];
|
|
|
|
log(s: any): void { this.res.push(s); }
|
2015-08-24 14:35:27 -04:00
|
|
|
logError(s: any): void { this.res.push(s); }
|
2015-08-07 14:41:38 -04:00
|
|
|
logGroup(s: any): void { this.res.push(s); }
|
|
|
|
logGroupEnd(){};
|
|
|
|
}
|
|
|
|
|
2015-12-15 11:34:44 -05:00
|
|
|
class DummyConsole implements Console {
|
2016-06-08 18:45:15 -04:00
|
|
|
log(message: any /** TODO #9100 */) {}
|
|
|
|
warn(message: any /** TODO #9100 */) {}
|
2015-12-15 11:34:44 -05:00
|
|
|
}
|
|
|
|
|
2015-07-13 19:12:48 -04:00
|
|
|
export function main() {
|
|
|
|
describe('RouteConfig with POJO arguments', () => {
|
2016-06-08 19:38:52 -04:00
|
|
|
var fakeDoc: any /** TODO #9100 */, el: any /** TODO #9100 */,
|
|
|
|
testBindings: any /** TODO #9100 */;
|
2015-07-13 19:12:48 -04:00
|
|
|
beforeEach(() => {
|
feat(testing): add implicit test module
Every test now has an implicit module. It can be configured via `configureModule` (from @angular/core/testing)
to add providers, directives, pipes, ...
The compiler now has to be configured separately via `configureCompiler` (from @angular/core/testing)
to add providers or define whether to use jit.
BREAKING CHANGE:
- Application providers can no longer inject compiler internals (i.e. everything
from `@angular/compiler). Inject `Compiler` instead. This reflects the
changes to `bootstrap` for module support (3f55aa609f60f130f1d69188ed057214b1267cb3).
- Compiler providers can no longer be added via `addProviders` / `withProviders`.
Use the new method `configureCompiler` instead.
- Platform directives / pipes need to be provided via
`configureModule` and can no longer be provided via the
`PLATFORM_PIPES` / `PLATFORM_DIRECTIVES` tokens.
- `setBaseTestProviders()` was renamed into `initTestEnvironment` and
now takes a `PlatformRef` and a factory for a
`Compiler`.
- E.g. for the browser platform:
BEFORE:
```
import {setBaseTestProviders} from ‘@angular/core/testing’;
import {TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS} from ‘@angular/platform-browser-dynamic/testing’;
setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
```
AFTER:
```
import {setBaseTestProviders} from ‘@angular/core/testing’;
import {browserTestCompiler, browserDynamicTestPlatform,
BrowserDynamicTestModule} from ‘@angular/platform-browser-dynamic/testing’;
initTestEnvironment(
browserTestCompiler,
browserDynamicTestPlatform(),
BrowserDynamicTestModule);
```
- E.g. for the server platform:
BEFORE:
```
import {setBaseTestProviders} from ‘@angular/core/testing’;
import {TEST_SERVER_PLATFORM_PROVIDERS,
TEST_SERVER_APPLICATION_PROVIDERS} from ‘@angular/platform-server/testing/server’;
setBaseTestProviders(TEST_SERVER_PLATFORM_PROVIDERS,
TEST_SERVER_APPLICATION_PROVIDERS);
```
AFTER:
```
import {setBaseTestProviders} from ‘@angular/core/testing’;
import {serverTestCompiler, serverTestPlatform,
ServerTestModule} from ‘@angular/platform-browser-dynamic/testing’;
initTestEnvironment(
serverTestCompiler,
serverTestPlatform(),
ServerTestModule);
```
Related to #9726
Closes #9846
2016-07-04 12:37:30 -04:00
|
|
|
disposePlatform();
|
2016-04-28 20:50:03 -04:00
|
|
|
fakeDoc = getDOM().createHtmlDocument();
|
|
|
|
el = getDOM().createElement('app-cmp', fakeDoc);
|
|
|
|
getDOM().appendChild(fakeDoc.body, el);
|
2015-08-07 14:41:38 -04:00
|
|
|
var logger = new _ArrayLogger();
|
2016-02-25 17:24:17 -05:00
|
|
|
var exceptionHandler = new ExceptionHandler(logger, false);
|
2015-07-13 19:12:48 -04:00
|
|
|
testBindings = [
|
2016-06-08 19:38:52 -04:00
|
|
|
ROUTER_PROVIDERS, {provide: LocationStrategy, useClass: MockLocationStrategy},
|
2016-06-02 20:30:40 -04:00
|
|
|
{provide: DOCUMENT, useValue: fakeDoc},
|
|
|
|
{provide: ExceptionHandler, useValue: exceptionHandler},
|
|
|
|
{provide: Console, useClass: DummyConsole}
|
2015-07-13 19:12:48 -04:00
|
|
|
];
|
|
|
|
});
|
|
|
|
|
feat(testing): add implicit test module
Every test now has an implicit module. It can be configured via `configureModule` (from @angular/core/testing)
to add providers, directives, pipes, ...
The compiler now has to be configured separately via `configureCompiler` (from @angular/core/testing)
to add providers or define whether to use jit.
BREAKING CHANGE:
- Application providers can no longer inject compiler internals (i.e. everything
from `@angular/compiler). Inject `Compiler` instead. This reflects the
changes to `bootstrap` for module support (3f55aa609f60f130f1d69188ed057214b1267cb3).
- Compiler providers can no longer be added via `addProviders` / `withProviders`.
Use the new method `configureCompiler` instead.
- Platform directives / pipes need to be provided via
`configureModule` and can no longer be provided via the
`PLATFORM_PIPES` / `PLATFORM_DIRECTIVES` tokens.
- `setBaseTestProviders()` was renamed into `initTestEnvironment` and
now takes a `PlatformRef` and a factory for a
`Compiler`.
- E.g. for the browser platform:
BEFORE:
```
import {setBaseTestProviders} from ‘@angular/core/testing’;
import {TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS} from ‘@angular/platform-browser-dynamic/testing’;
setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
```
AFTER:
```
import {setBaseTestProviders} from ‘@angular/core/testing’;
import {browserTestCompiler, browserDynamicTestPlatform,
BrowserDynamicTestModule} from ‘@angular/platform-browser-dynamic/testing’;
initTestEnvironment(
browserTestCompiler,
browserDynamicTestPlatform(),
BrowserDynamicTestModule);
```
- E.g. for the server platform:
BEFORE:
```
import {setBaseTestProviders} from ‘@angular/core/testing’;
import {TEST_SERVER_PLATFORM_PROVIDERS,
TEST_SERVER_APPLICATION_PROVIDERS} from ‘@angular/platform-server/testing/server’;
setBaseTestProviders(TEST_SERVER_PLATFORM_PROVIDERS,
TEST_SERVER_APPLICATION_PROVIDERS);
```
AFTER:
```
import {setBaseTestProviders} from ‘@angular/core/testing’;
import {serverTestCompiler, serverTestPlatform,
ServerTestModule} from ‘@angular/platform-browser-dynamic/testing’;
initTestEnvironment(
serverTestCompiler,
serverTestPlatform(),
ServerTestModule);
```
Related to #9726
Closes #9846
2016-07-04 12:37:30 -04:00
|
|
|
afterEach(() => disposePlatform());
|
|
|
|
|
2016-06-08 19:38:52 -04:00
|
|
|
it('should bootstrap an app with a hierarchy',
|
|
|
|
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
|
|
|
bootstrap(HierarchyAppCmp, testBindings).then((applicationRef) => {
|
|
|
|
var router = applicationRef.instance.router;
|
|
|
|
router.subscribe((_: any /** TODO #9100 */) => {
|
2016-06-30 17:59:23 -04:00
|
|
|
expect(el).toHaveText('root [ parent [ hello ] ]');
|
2016-06-08 19:38:52 -04:00
|
|
|
expect(applicationRef.instance.location.path()).toEqual('/parent/child');
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
router.navigateByUrl('/parent/child');
|
|
|
|
});
|
2015-09-09 10:41:11 -04:00
|
|
|
}));
|
2015-07-13 19:12:48 -04:00
|
|
|
|
|
|
|
|
2016-06-08 19:38:52 -04:00
|
|
|
it('should work in an app with redirects',
|
|
|
|
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
|
|
|
bootstrap(RedirectAppCmp, testBindings).then((applicationRef) => {
|
|
|
|
var router = applicationRef.instance.router;
|
|
|
|
router.subscribe((_: any /** TODO #9100 */) => {
|
2016-06-30 17:59:23 -04:00
|
|
|
expect(el).toHaveText('root [ hello ]');
|
2016-06-08 19:38:52 -04:00
|
|
|
expect(applicationRef.instance.location.path()).toEqual('/after');
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
router.navigateByUrl('/before');
|
|
|
|
});
|
2015-09-09 10:41:11 -04:00
|
|
|
}));
|
2015-07-13 19:12:48 -04:00
|
|
|
|
|
|
|
|
2016-06-08 19:38:52 -04:00
|
|
|
it('should work in an app with async components',
|
|
|
|
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
|
|
|
bootstrap(AsyncAppCmp, testBindings).then((applicationRef) => {
|
|
|
|
var router = applicationRef.instance.router;
|
|
|
|
router.subscribe((_: any /** TODO #9100 */) => {
|
2016-06-30 17:59:23 -04:00
|
|
|
expect(el).toHaveText('root [ hello ]');
|
2016-06-08 19:38:52 -04:00
|
|
|
expect(applicationRef.instance.location.path()).toEqual('/hello');
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
router.navigateByUrl('/hello');
|
|
|
|
});
|
2015-09-09 10:41:11 -04:00
|
|
|
}));
|
2015-07-13 19:12:48 -04:00
|
|
|
|
|
|
|
|
2016-06-08 19:38:52 -04:00
|
|
|
it('should work in an app with aux routes',
|
|
|
|
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
|
|
|
bootstrap(AuxAppCmp, testBindings).then((applicationRef) => {
|
|
|
|
var router = applicationRef.instance.router;
|
|
|
|
router.subscribe((_: any /** TODO #9100 */) => {
|
2016-06-30 17:59:23 -04:00
|
|
|
expect(el).toHaveText('root [ hello ] aside [ hello ]');
|
2016-06-08 19:38:52 -04:00
|
|
|
expect(applicationRef.instance.location.path()).toEqual('/hello(aside)');
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
router.navigateByUrl('/hello(aside)');
|
|
|
|
});
|
2015-10-30 20:05:30 -04:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-10-08 15:27:55 -04:00
|
|
|
it('should work in an app with async components defined with "loader"',
|
2016-06-09 14:04:15 -04:00
|
|
|
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
2016-06-08 19:38:52 -04:00
|
|
|
bootstrap(ConciseAsyncAppCmp, testBindings).then((applicationRef) => {
|
|
|
|
var router = applicationRef.instance.router;
|
|
|
|
router.subscribe((_: any /** TODO #9100 */) => {
|
2016-06-30 17:59:23 -04:00
|
|
|
expect(el).toHaveText('root [ hello ]');
|
2016-06-08 19:38:52 -04:00
|
|
|
expect(applicationRef.instance.location.path()).toEqual('/hello');
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
router.navigateByUrl('/hello');
|
|
|
|
});
|
2015-10-08 15:27:55 -04:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-07-13 19:12:48 -04:00
|
|
|
it('should work in an app with a constructor component',
|
2016-06-09 14:04:15 -04:00
|
|
|
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
2016-06-08 19:38:52 -04:00
|
|
|
bootstrap(ExplicitConstructorAppCmp, testBindings).then((applicationRef) => {
|
|
|
|
var router = applicationRef.instance.router;
|
|
|
|
router.subscribe((_: any /** TODO #9100 */) => {
|
2016-06-30 17:59:23 -04:00
|
|
|
expect(el).toHaveText('root [ hello ]');
|
2016-06-08 19:38:52 -04:00
|
|
|
expect(applicationRef.instance.location.path()).toEqual('/hello');
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
router.navigateByUrl('/hello');
|
|
|
|
});
|
2015-09-09 10:41:11 -04:00
|
|
|
}));
|
2015-07-13 19:12:48 -04:00
|
|
|
|
2015-07-17 16:36:53 -04:00
|
|
|
it('should throw if a config is missing a target',
|
|
|
|
inject(
|
|
|
|
[AsyncTestCompleter],
|
2016-06-08 19:38:52 -04:00
|
|
|
(async: AsyncTestCompleter) => {bootstrap(WrongConfigCmp, testBindings).catch((e) => {
|
|
|
|
expect(e.originalException)
|
|
|
|
.toContainError(
|
|
|
|
'Route config should contain exactly one "component", "loader", or "redirectTo" property.');
|
|
|
|
async.done();
|
|
|
|
return null;
|
|
|
|
})}));
|
2015-07-17 16:36:53 -04:00
|
|
|
|
|
|
|
it('should throw if a config has an invalid component type',
|
|
|
|
inject(
|
|
|
|
[AsyncTestCompleter],
|
2016-06-08 19:38:52 -04:00
|
|
|
(async:
|
|
|
|
AsyncTestCompleter) => {bootstrap(WrongComponentTypeCmp, testBindings).catch((e) => {
|
|
|
|
expect(e.originalException)
|
|
|
|
.toContainError(
|
|
|
|
'Invalid component type "intentionallyWrongComponentType". Valid types are "constructor" and "loader".');
|
|
|
|
async.done();
|
|
|
|
return null;
|
|
|
|
})}));
|
2015-09-14 19:01:09 -04:00
|
|
|
|
|
|
|
it('should throw if a config has an invalid alias name',
|
2015-10-25 05:30:27 -04:00
|
|
|
inject(
|
|
|
|
[AsyncTestCompleter],
|
2016-06-08 19:38:52 -04:00
|
|
|
(async: AsyncTestCompleter) => {bootstrap(BadAliasNameCmp, testBindings).catch((e) => {
|
|
|
|
expect(e.originalException)
|
|
|
|
.toContainError(
|
|
|
|
`Route "/child" with name "child" does not begin with an uppercase letter. Route names should be PascalCase like "Child".`);
|
|
|
|
async.done();
|
|
|
|
return null;
|
|
|
|
})}));
|
2015-10-25 05:30:27 -04:00
|
|
|
|
2015-07-13 19:12:48 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-08 16:36:48 -05:00
|
|
|
@Component({selector: 'hello-cmp', template: 'hello'})
|
2015-07-13 19:12:48 -04:00
|
|
|
class HelloCmp {
|
|
|
|
}
|
|
|
|
|
2016-03-08 16:36:48 -05:00
|
|
|
@Component({
|
|
|
|
selector: 'app-cmp',
|
2016-06-30 17:59:23 -04:00
|
|
|
template: `root [ <router-outlet></router-outlet> ]`,
|
2016-03-08 16:36:48 -05:00
|
|
|
directives: ROUTER_DIRECTIVES
|
|
|
|
})
|
refactor(router): improve recognition and generation pipeline
This is a big change. @matsko also deserves much of the credit for the implementation.
Previously, `ComponentInstruction`s held all the state for async components.
Now, we introduce several subclasses for `Instruction` to describe each type of navigation.
BREAKING CHANGE:
Redirects now use the Link DSL syntax. Before:
```
@RouteConfig([
{ path: '/foo', redirectTo: '/bar' },
{ path: '/bar', component: BarCmp }
])
```
After:
```
@RouteConfig([
{ path: '/foo', redirectTo: ['Bar'] },
{ path: '/bar', component: BarCmp, name: 'Bar' }
])
```
BREAKING CHANGE:
This also introduces `useAsDefault` in the RouteConfig, which makes cases like lazy-loading
and encapsulating large routes with sub-routes easier.
Previously, you could use `redirectTo` like this to expand a URL like `/tab` to `/tab/posts`:
@RouteConfig([
{ path: '/tab', redirectTo: '/tab/users' }
{ path: '/tab', component: TabsCmp, name: 'Tab' }
])
AppCmp { ... }
Now the recommended way to handle this is case is to use `useAsDefault` like so:
```
@RouteConfig([
{ path: '/tab', component: TabsCmp, name: 'Tab' }
])
AppCmp { ... }
@RouteConfig([
{ path: '/posts', component: PostsCmp, useAsDefault: true, name: 'Posts' },
{ path: '/users', component: UsersCmp, name: 'Users' }
])
TabsCmp { ... }
```
In the above example, you can write just `['/Tab']` and the route `Users` is automatically selected as a child route.
Closes #4728
Closes #4228
Closes #4170
Closes #4490
Closes #4694
Closes #5200
Closes #5475
2015-11-23 21:07:37 -05:00
|
|
|
@RouteConfig([
|
2016-06-08 19:38:52 -04:00
|
|
|
{path: '/before', redirectTo: ['Hello']}, {path: '/after', component: HelloCmp, name: 'Hello'}
|
refactor(router): improve recognition and generation pipeline
This is a big change. @matsko also deserves much of the credit for the implementation.
Previously, `ComponentInstruction`s held all the state for async components.
Now, we introduce several subclasses for `Instruction` to describe each type of navigation.
BREAKING CHANGE:
Redirects now use the Link DSL syntax. Before:
```
@RouteConfig([
{ path: '/foo', redirectTo: '/bar' },
{ path: '/bar', component: BarCmp }
])
```
After:
```
@RouteConfig([
{ path: '/foo', redirectTo: ['Bar'] },
{ path: '/bar', component: BarCmp, name: 'Bar' }
])
```
BREAKING CHANGE:
This also introduces `useAsDefault` in the RouteConfig, which makes cases like lazy-loading
and encapsulating large routes with sub-routes easier.
Previously, you could use `redirectTo` like this to expand a URL like `/tab` to `/tab/posts`:
@RouteConfig([
{ path: '/tab', redirectTo: '/tab/users' }
{ path: '/tab', component: TabsCmp, name: 'Tab' }
])
AppCmp { ... }
Now the recommended way to handle this is case is to use `useAsDefault` like so:
```
@RouteConfig([
{ path: '/tab', component: TabsCmp, name: 'Tab' }
])
AppCmp { ... }
@RouteConfig([
{ path: '/posts', component: PostsCmp, useAsDefault: true, name: 'Posts' },
{ path: '/users', component: UsersCmp, name: 'Users' }
])
TabsCmp { ... }
```
In the above example, you can write just `['/Tab']` and the route `Users` is automatically selected as a child route.
Closes #4728
Closes #4228
Closes #4170
Closes #4490
Closes #4694
Closes #5200
Closes #5475
2015-11-23 21:07:37 -05:00
|
|
|
])
|
2015-07-13 19:12:48 -04:00
|
|
|
class RedirectAppCmp {
|
|
|
|
constructor(public router: Router, public location: LocationStrategy) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
function HelloLoader(): Promise<any> {
|
|
|
|
return Promise.resolve(HelloCmp);
|
|
|
|
}
|
|
|
|
|
2016-03-08 16:36:48 -05:00
|
|
|
@Component({
|
|
|
|
selector: 'app-cmp',
|
2016-06-30 17:59:23 -04:00
|
|
|
template: `root [ <router-outlet></router-outlet> ]`,
|
2016-03-08 16:36:48 -05:00
|
|
|
directives: ROUTER_DIRECTIVES
|
|
|
|
})
|
2015-07-13 19:12:48 -04:00
|
|
|
@RouteConfig([
|
|
|
|
{path: '/hello', component: {type: 'loader', loader: HelloLoader}},
|
|
|
|
])
|
|
|
|
class AsyncAppCmp {
|
|
|
|
constructor(public router: Router, public location: LocationStrategy) {}
|
|
|
|
}
|
|
|
|
|
2016-03-08 16:36:48 -05:00
|
|
|
@Component({
|
|
|
|
selector: 'app-cmp',
|
2016-06-30 17:59:23 -04:00
|
|
|
template: `root [ <router-outlet></router-outlet> ]`,
|
2016-03-08 16:36:48 -05:00
|
|
|
directives: ROUTER_DIRECTIVES
|
|
|
|
})
|
2015-10-08 15:27:55 -04:00
|
|
|
@RouteConfig([
|
|
|
|
{path: '/hello', loader: HelloLoader},
|
|
|
|
])
|
|
|
|
class ConciseAsyncAppCmp {
|
2015-10-30 20:05:30 -04:00
|
|
|
constructor(public router: Router, public location: LocationStrategy) {}
|
|
|
|
}
|
|
|
|
|
2016-03-08 16:36:48 -05:00
|
|
|
@Component({
|
|
|
|
selector: 'app-cmp',
|
2016-06-08 19:38:52 -04:00
|
|
|
template:
|
2016-06-30 17:59:23 -04:00
|
|
|
`root [ <router-outlet></router-outlet> ] aside [ <router-outlet name="aside"></router-outlet> ]`,
|
2016-03-08 16:36:48 -05:00
|
|
|
directives: ROUTER_DIRECTIVES
|
|
|
|
})
|
2015-10-30 20:05:30 -04:00
|
|
|
@RouteConfig([{path: '/hello', component: HelloCmp}, {aux: 'aside', component: HelloCmp}])
|
|
|
|
class AuxAppCmp {
|
2015-10-08 15:27:55 -04:00
|
|
|
constructor(public router: Router, public location: LocationStrategy) {}
|
|
|
|
}
|
|
|
|
|
2016-03-08 16:36:48 -05:00
|
|
|
@Component({
|
|
|
|
selector: 'app-cmp',
|
2016-06-30 17:59:23 -04:00
|
|
|
template: `root [ <router-outlet></router-outlet> ]`,
|
2016-03-08 16:36:48 -05:00
|
|
|
directives: ROUTER_DIRECTIVES
|
|
|
|
})
|
2015-07-13 19:12:48 -04:00
|
|
|
@RouteConfig([
|
|
|
|
{path: '/hello', component: {type: 'constructor', constructor: HelloCmp}},
|
|
|
|
])
|
|
|
|
class ExplicitConstructorAppCmp {
|
|
|
|
constructor(public router: Router, public location: LocationStrategy) {}
|
|
|
|
}
|
|
|
|
|
2016-03-08 16:36:48 -05:00
|
|
|
@Component({
|
|
|
|
selector: 'parent-cmp',
|
2016-06-30 17:59:23 -04:00
|
|
|
template: `parent [ <router-outlet></router-outlet> ]`,
|
2016-03-08 16:36:48 -05:00
|
|
|
directives: ROUTER_DIRECTIVES
|
|
|
|
})
|
2015-07-13 19:12:48 -04:00
|
|
|
@RouteConfig([{path: '/child', component: HelloCmp}])
|
|
|
|
class ParentCmp {
|
|
|
|
}
|
|
|
|
|
2016-03-08 16:36:48 -05:00
|
|
|
@Component({
|
|
|
|
selector: 'app-cmp',
|
2016-06-30 17:59:23 -04:00
|
|
|
template: `root [ <router-outlet></router-outlet> ]`,
|
2016-03-08 16:36:48 -05:00
|
|
|
directives: ROUTER_DIRECTIVES
|
|
|
|
})
|
2015-07-13 19:12:48 -04:00
|
|
|
@RouteConfig([{path: '/parent/...', component: ParentCmp}])
|
|
|
|
class HierarchyAppCmp {
|
|
|
|
constructor(public router: Router, public location: LocationStrategy) {}
|
|
|
|
}
|
2015-07-17 16:36:53 -04:00
|
|
|
|
2016-03-08 16:36:48 -05:00
|
|
|
@Component({
|
|
|
|
selector: 'app-cmp',
|
2016-06-30 17:59:23 -04:00
|
|
|
template: `root [ <router-outlet></router-outlet> ]`,
|
2016-03-08 16:36:48 -05:00
|
|
|
directives: ROUTER_DIRECTIVES
|
|
|
|
})
|
2015-07-17 16:36:53 -04:00
|
|
|
@RouteConfig([{path: '/hello'}])
|
|
|
|
class WrongConfigCmp {
|
|
|
|
}
|
|
|
|
|
2016-03-08 16:36:48 -05:00
|
|
|
@Component({
|
|
|
|
selector: 'app-cmp',
|
2016-06-30 17:59:23 -04:00
|
|
|
template: `root [ <router-outlet></router-outlet> ]`,
|
2016-03-08 16:36:48 -05:00
|
|
|
directives: ROUTER_DIRECTIVES
|
|
|
|
})
|
2015-10-25 05:30:27 -04:00
|
|
|
@RouteConfig([{path: '/child', component: HelloCmp, name: 'child'}])
|
|
|
|
class BadAliasNameCmp {
|
|
|
|
}
|
|
|
|
|
2016-03-08 16:36:48 -05:00
|
|
|
@Component({
|
|
|
|
selector: 'app-cmp',
|
2016-06-30 17:59:23 -04:00
|
|
|
template: `root [ <router-outlet></router-outlet> ]`,
|
2016-03-08 16:36:48 -05:00
|
|
|
directives: ROUTER_DIRECTIVES
|
|
|
|
})
|
2015-07-17 16:36:53 -04:00
|
|
|
@RouteConfig([
|
|
|
|
{path: '/hello', component: {type: 'intentionallyWrongComponentType', constructor: HelloCmp}},
|
|
|
|
])
|
|
|
|
class WrongComponentTypeCmp {
|
|
|
|
}
|