refactor(router): use CamelCase aliases for routes
This commit is contained in:
parent
97d1844bfc
commit
cb4a9a3c04
|
@ -38,9 +38,9 @@ describe('ngOutlet', function () {
|
|||
|
||||
$router.config([
|
||||
{ path: '/a', component: OneController },
|
||||
{ path: '/b', component: TwoController, as: 'two' }
|
||||
{ path: '/b', component: TwoController, as: 'Two' }
|
||||
]);
|
||||
compile('<a ng-link="[\'/two\']">link</a> | outer { <div ng-outlet></div> }');
|
||||
compile('<a ng-link="[\'/Two\']">link</a> | outer { <div ng-outlet></div> }');
|
||||
|
||||
$router.navigateByUrl('/a');
|
||||
$rootScope.$digest();
|
||||
|
@ -49,11 +49,11 @@ describe('ngOutlet', function () {
|
|||
});
|
||||
|
||||
it('should allow linking from the child and the parent', function () {
|
||||
put('one', '<div><a ng-link="[\'/two\']">{{number}}</a></div>');
|
||||
put('one', '<div><a ng-link="[\'/Two\']">{{number}}</a></div>');
|
||||
|
||||
$router.config([
|
||||
{ path: '/a', component: OneController },
|
||||
{ path: '/b', component: TwoController, as: 'two' }
|
||||
{ path: '/b', component: TwoController, as: 'Two' }
|
||||
]);
|
||||
compile('outer { <div ng-outlet></div> }');
|
||||
|
||||
|
@ -66,11 +66,11 @@ describe('ngOutlet', function () {
|
|||
|
||||
it('should allow params in routerLink directive', function () {
|
||||
put('router', '<div>outer { <div ng-outlet></div> }</div>');
|
||||
put('one', '<div><a ng-link="[\'/two\', {param: \'lol\'}]">{{number}}</a></div>');
|
||||
put('one', '<div><a ng-link="[\'/Two\', {param: \'lol\'}]">{{number}}</a></div>');
|
||||
|
||||
$router.config([
|
||||
{ path: '/a', component: OneController },
|
||||
{ path: '/b/:param', component: TwoController, as: 'two' }
|
||||
{ path: '/b/:param', component: TwoController, as: 'Two' }
|
||||
]);
|
||||
compile('<div ng-outlet></div>');
|
||||
|
||||
|
@ -83,11 +83,11 @@ describe('ngOutlet', function () {
|
|||
// TODO: test dynamic links
|
||||
it('should update the href of links with bound params', function () {
|
||||
put('router', '<div>outer { <div ng-outlet></div> }</div>');
|
||||
put('one', '<div><a ng-link="[\'/two\', {param: one.number}]">{{one.number}}</a></div>');
|
||||
put('one', '<div><a ng-link="[\'/Two\', {param: one.number}]">{{one.number}}</a></div>');
|
||||
|
||||
$router.config([
|
||||
{ path: '/a', component: OneController },
|
||||
{ path: '/b/:param', component: TwoController, as: 'two' }
|
||||
{ path: '/b/:param', component: TwoController, as: 'Two' }
|
||||
]);
|
||||
compile('<div ng-outlet></div>');
|
||||
|
||||
|
|
|
@ -72,9 +72,9 @@ export function main() {
|
|||
it('should generate absolute hrefs that include the base href',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
location.setBaseHref('/my/base');
|
||||
compile('<a href="hello" [router-link]="[\'./user\']"></a>')
|
||||
compile('<a href="hello" [router-link]="[\'./User\']"></a>')
|
||||
.then((_) =>
|
||||
router.config([new Route({path: '/user', component: UserCmp, as: 'user'})]))
|
||||
router.config([new Route({path: '/user', component: UserCmp, as: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
|
@ -85,9 +85,9 @@ export function main() {
|
|||
|
||||
|
||||
it('should generate link hrefs without params', inject([AsyncTestCompleter], (async) => {
|
||||
compile('<a href="hello" [router-link]="[\'./user\']"></a>')
|
||||
compile('<a href="hello" [router-link]="[\'./User\']"></a>')
|
||||
.then((_) =>
|
||||
router.config([new Route({path: '/user', component: UserCmp, as: 'user'})]))
|
||||
router.config([new Route({path: '/user', component: UserCmp, as: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
|
@ -98,9 +98,9 @@ export function main() {
|
|||
|
||||
|
||||
it('should generate link hrefs with params', inject([AsyncTestCompleter], (async) => {
|
||||
compile('<a href="hello" [router-link]="[\'./user\', {name: name}]">{{name}}</a>')
|
||||
compile('<a href="hello" [router-link]="[\'./User\', {name: name}]">{{name}}</a>')
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/user/:name', component: UserCmp, as: 'user'})]))
|
||||
[new Route({path: '/user/:name', component: UserCmp, as: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.debugElement.componentInstance.name = 'brian';
|
||||
|
@ -117,7 +117,7 @@ export function main() {
|
|||
inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/page/:number', component: SiblingPageCmp, as: 'page'})]))
|
||||
[new Route({path: '/page/:number', component: SiblingPageCmp, as: 'Page'})]))
|
||||
.then((_) => router.navigateByUrl('/page/1'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
|
@ -137,10 +137,10 @@ export function main() {
|
|||
new AsyncRoute({
|
||||
path: '/child-with-grandchild/...',
|
||||
loader: parentCmpLoader,
|
||||
as: 'child-with-grandchild'
|
||||
as: 'ChildWithGrandchild'
|
||||
})
|
||||
]))
|
||||
.then((_) => router.navigate(['/child-with-grandchild']))
|
||||
.then((_) => router.navigate(['/ChildWithGrandchild']))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[1]
|
||||
|
@ -156,7 +156,7 @@ export function main() {
|
|||
inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/book/:title/...', component: BookCmp, as: 'book'})]))
|
||||
[new Route({path: '/book/:title/...', component: BookCmp, as: 'Book'})]))
|
||||
.then((_) => router.navigateByUrl('/book/1984/page/1'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
|
@ -180,11 +180,11 @@ export function main() {
|
|||
describe('router-link-active CSS class', () => {
|
||||
it('should be added to the associated element', inject([AsyncTestCompleter], (async) => {
|
||||
router.config([
|
||||
new Route({path: '/child', component: HelloCmp, as: 'child'}),
|
||||
new Route({path: '/better-child', component: Hello2Cmp, as: 'better-child'})
|
||||
new Route({path: '/child', component: HelloCmp, as: 'Child'}),
|
||||
new Route({path: '/better-child', component: Hello2Cmp, as: 'BetterChild'})
|
||||
])
|
||||
.then((_) => compile(`<a [router-link]="['./child']" class="child-link">Child</a>
|
||||
<a [router-link]="['./better-child']" class="better-child-link">Better Child</a>
|
||||
.then((_) => compile(`<a [router-link]="['./Child']" class="child-link">Child</a>
|
||||
<a [router-link]="['./BetterChild']" class="better-child-link">Better Child</a>
|
||||
<router-outlet></router-outlet>`))
|
||||
.then((_) => {
|
||||
var element = rootTC.debugElement.nativeElement;
|
||||
|
@ -211,15 +211,15 @@ export function main() {
|
|||
|
||||
it('should be added to links in child routes', inject([AsyncTestCompleter], (async) => {
|
||||
router.config([
|
||||
new Route({path: '/child', component: HelloCmp, as: 'child'}),
|
||||
new Route({path: '/child', component: HelloCmp, as: 'Child'}),
|
||||
new Route({
|
||||
path: '/child-with-grandchild/...',
|
||||
component: ParentCmp,
|
||||
as: 'child-with-grandchild'
|
||||
as: 'ChildWithGrandchild'
|
||||
})
|
||||
])
|
||||
.then((_) => compile(`<a [router-link]="['./child']" class="child-link">Child</a>
|
||||
<a [router-link]="['./child-with-grandchild/grandchild']" class="child-with-grandchild-link">Better Child</a>
|
||||
.then((_) => compile(`<a [router-link]="['./Child']" class="child-link">Child</a>
|
||||
<a [router-link]="['./ChildWithGrandchild/Grandchild']" class="child-with-grandchild-link">Better Child</a>
|
||||
<router-outlet></router-outlet>`))
|
||||
.then((_) => {
|
||||
var element = rootTC.debugElement.nativeElement;
|
||||
|
@ -261,9 +261,9 @@ export function main() {
|
|||
};
|
||||
|
||||
it('should navigate to link hrefs without params', inject([AsyncTestCompleter], (async) => {
|
||||
compile('<a href="hello" [router-link]="[\'./user\']"></a>')
|
||||
compile('<a href="hello" [router-link]="[\'./User\']"></a>')
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/user', component: UserCmp, as: 'user'})]))
|
||||
[new Route({path: '/user', component: UserCmp, as: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
|
@ -282,9 +282,9 @@ export function main() {
|
|||
it('should navigate to link hrefs in presence of base href',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
location.setBaseHref('/base');
|
||||
compile('<a href="hello" [router-link]="[\'./user\']"></a>')
|
||||
compile('<a href="hello" [router-link]="[\'./User\']"></a>')
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/user', component: UserCmp, as: 'user'})]))
|
||||
[new Route({path: '/user', component: UserCmp, as: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
|
@ -322,7 +322,7 @@ class UserCmp {
|
|||
@Component({selector: 'page-cmp'})
|
||||
@View({
|
||||
template:
|
||||
`page #{{pageNumber}} | <a href="hello" [router-link]="[\'../page\', {number: nextPage}]">next</a>`,
|
||||
`page #{{pageNumber}} | <a href="hello" [router-link]="[\'../Page\', {number: nextPage}]">next</a>`,
|
||||
directives: [RouterLink]
|
||||
})
|
||||
class SiblingPageCmp {
|
||||
|
@ -350,14 +350,14 @@ function parentCmpLoader() {
|
|||
|
||||
@Component({selector: 'parent-cmp'})
|
||||
@View({
|
||||
template: `{ <a [router-link]="['./grandchild']" class="grandchild-link">Grandchild</a>
|
||||
<a [router-link]="['./better-grandchild']" class="better-grandchild-link">Better Grandchild</a>
|
||||
template: `{ <a [router-link]="['./Grandchild']" class="grandchild-link">Grandchild</a>
|
||||
<a [router-link]="['./BetterGrandchild']" class="better-grandchild-link">Better Grandchild</a>
|
||||
<router-outlet></router-outlet> }`,
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
@RouteConfig([
|
||||
new Route({path: '/grandchild', component: HelloCmp, as: 'grandchild'}),
|
||||
new Route({path: '/better-grandchild', component: Hello2Cmp, as: 'better-grandchild'})
|
||||
new Route({path: '/grandchild', component: HelloCmp, as: 'Grandchild'}),
|
||||
new Route({path: '/better-grandchild', component: Hello2Cmp, as: 'BetterGrandchild'})
|
||||
])
|
||||
class ParentCmp {
|
||||
constructor(public router: Router) {}
|
||||
|
@ -365,11 +365,11 @@ class ParentCmp {
|
|||
|
||||
@Component({selector: 'book-cmp'})
|
||||
@View({
|
||||
template: `<a href="hello" [router-link]="[\'./page\', {number: 100}]">{{title}}</a> |
|
||||
template: `<a href="hello" [router-link]="[\'./Page\', {number: 100}]">{{title}}</a> |
|
||||
<router-outlet></router-outlet>`,
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
@RouteConfig([new Route({path: '/page/:number', component: SiblingPageCmp, as: 'page'})])
|
||||
@RouteConfig([new Route({path: '/page/:number', component: SiblingPageCmp, as: 'Page'})])
|
||||
class BookCmp {
|
||||
title: string;
|
||||
constructor(params: RouteParams) { this.title = params.get('title'); }
|
||||
|
|
|
@ -108,28 +108,28 @@ export function main() {
|
|||
|
||||
|
||||
it('should generate URLs with params', () => {
|
||||
recognizer.config(new Route({path: '/app/user/:name', component: DummyCmpA, as: 'user'}));
|
||||
var instruction = recognizer.generate('user', {'name': 'misko'});
|
||||
recognizer.config(new Route({path: '/app/user/:name', component: DummyCmpA, as: 'User'}));
|
||||
var instruction = recognizer.generate('User', {'name': 'misko'});
|
||||
expect(instruction.urlPath).toEqual('app/user/misko');
|
||||
});
|
||||
|
||||
|
||||
it('should generate URLs with numeric params', () => {
|
||||
recognizer.config(new Route({path: '/app/page/:number', component: DummyCmpA, as: 'page'}));
|
||||
expect(recognizer.generate('page', {'number': 42}).urlPath).toEqual('app/page/42');
|
||||
recognizer.config(new Route({path: '/app/page/:number', component: DummyCmpA, as: 'Page'}));
|
||||
expect(recognizer.generate('Page', {'number': 42}).urlPath).toEqual('app/page/42');
|
||||
});
|
||||
|
||||
|
||||
it('should throw in the absence of required params URLs', () => {
|
||||
recognizer.config(new Route({path: 'app/user/:name', component: DummyCmpA, as: 'user'}));
|
||||
expect(() => recognizer.generate('user', {}))
|
||||
recognizer.config(new Route({path: 'app/user/:name', component: DummyCmpA, as: 'User'}));
|
||||
expect(() => recognizer.generate('User', {}))
|
||||
.toThrowError('Route generator for \'name\' was not included in parameters passed.');
|
||||
});
|
||||
|
||||
|
||||
describe('params', () => {
|
||||
it('should recognize parameters within the URL path', () => {
|
||||
recognizer.config(new Route({path: 'profile/:name', component: DummyCmpA, as: 'user'}));
|
||||
recognizer.config(new Route({path: 'profile/:name', component: DummyCmpA, as: 'User'}));
|
||||
var solution = recognize(recognizer, '/profile/matsko?comments=all');
|
||||
expect(solution.params).toEqual({'name': 'matsko', 'comments': 'all'});
|
||||
});
|
||||
|
@ -138,18 +138,18 @@ export function main() {
|
|||
it('should generate and populate the given static-based route with querystring params',
|
||||
() => {
|
||||
recognizer.config(
|
||||
new Route({path: 'forum/featured', component: DummyCmpA, as: 'forum-page'}));
|
||||
new Route({path: 'forum/featured', component: DummyCmpA, as: 'ForumPage'}));
|
||||
|
||||
var params = {'start': 10, 'end': 100};
|
||||
|
||||
var result = recognizer.generate('forum-page', params);
|
||||
var result = recognizer.generate('ForumPage', params);
|
||||
expect(result.urlPath).toEqual('forum/featured');
|
||||
expect(result.urlParams).toEqual(['start=10', 'end=100']);
|
||||
});
|
||||
|
||||
|
||||
it('should prefer positional params over query params', () => {
|
||||
recognizer.config(new Route({path: 'profile/:name', component: DummyCmpA, as: 'user'}));
|
||||
recognizer.config(new Route({path: 'profile/:name', component: DummyCmpA, as: 'User'}));
|
||||
|
||||
var solution = recognize(recognizer, '/profile/yegor?name=igor');
|
||||
expect(solution.params).toEqual({'name': 'yegor'});
|
||||
|
@ -157,7 +157,7 @@ export function main() {
|
|||
|
||||
|
||||
it('should ignore matrix params for the top-level component', () => {
|
||||
recognizer.config(new Route({path: '/home/:subject', component: DummyCmpA, as: 'user'}));
|
||||
recognizer.config(new Route({path: '/home/:subject', component: DummyCmpA, as: 'User'}));
|
||||
var solution = recognize(recognizer, '/home;sort=asc/zero;one=1?two=2');
|
||||
expect(solution.params).toEqual({'subject': 'zero', 'two': '2'});
|
||||
});
|
||||
|
|
|
@ -43,45 +43,45 @@ export function main() {
|
|||
|
||||
it('should generate URLs starting at the given component', () => {
|
||||
registry.config(RootHostCmp,
|
||||
new Route({path: '/first/...', component: DummyParentCmp, as: 'firstCmp'}));
|
||||
new Route({path: '/first/...', component: DummyParentCmp, as: 'FirstCmp'}));
|
||||
|
||||
expect(stringifyInstruction(registry.generate(['firstCmp', 'secondCmp'], RootHostCmp)))
|
||||
expect(stringifyInstruction(registry.generate(['FirstCmp', 'SecondCmp'], RootHostCmp)))
|
||||
.toEqual('first/second');
|
||||
expect(stringifyInstruction(registry.generate(['secondCmp'], DummyParentCmp)))
|
||||
expect(stringifyInstruction(registry.generate(['SecondCmp'], DummyParentCmp)))
|
||||
.toEqual('second');
|
||||
});
|
||||
|
||||
it('should generate URLs that account for redirects', () => {
|
||||
registry.config(
|
||||
RootHostCmp,
|
||||
new Route({path: '/first/...', component: DummyParentRedirectCmp, as: 'firstCmp'}));
|
||||
new Route({path: '/first/...', component: DummyParentRedirectCmp, as: 'FirstCmp'}));
|
||||
|
||||
expect(stringifyInstruction(registry.generate(['firstCmp'], RootHostCmp)))
|
||||
expect(stringifyInstruction(registry.generate(['FirstCmp'], RootHostCmp)))
|
||||
.toEqual('first/second');
|
||||
});
|
||||
|
||||
it('should generate URLs in a hierarchy of redirects', () => {
|
||||
registry.config(
|
||||
RootHostCmp,
|
||||
new Route({path: '/first/...', component: DummyMultipleRedirectCmp, as: 'firstCmp'}));
|
||||
new Route({path: '/first/...', component: DummyMultipleRedirectCmp, as: 'FirstCmp'}));
|
||||
|
||||
expect(stringifyInstruction(registry.generate(['firstCmp'], RootHostCmp)))
|
||||
expect(stringifyInstruction(registry.generate(['FirstCmp'], RootHostCmp)))
|
||||
.toEqual('first/second/third');
|
||||
});
|
||||
|
||||
it('should generate URLs with params', () => {
|
||||
registry.config(
|
||||
RootHostCmp,
|
||||
new Route({path: '/first/:param/...', component: DummyParentParamCmp, as: 'firstCmp'}));
|
||||
new Route({path: '/first/:param/...', component: DummyParentParamCmp, as: 'FirstCmp'}));
|
||||
|
||||
var url = stringifyInstruction(registry.generate(
|
||||
['firstCmp', {param: 'one'}, 'secondCmp', {param: 'two'}], RootHostCmp));
|
||||
['FirstCmp', {param: 'one'}, 'SecondCmp', {param: 'two'}], RootHostCmp));
|
||||
expect(url).toEqual('first/one/second/two');
|
||||
});
|
||||
|
||||
it('should generate params as an empty StringMap when no params are given', () => {
|
||||
registry.config(RootHostCmp, new Route({path: '/test', component: DummyCmpA, as: 'test'}));
|
||||
var instruction = registry.generate(['test'], RootHostCmp);
|
||||
registry.config(RootHostCmp, new Route({path: '/test', component: DummyCmpA, as: 'Test'}));
|
||||
var instruction = registry.generate(['Test'], RootHostCmp);
|
||||
expect(instruction.component.params).toEqual({});
|
||||
});
|
||||
|
||||
|
@ -89,15 +89,15 @@ export function main() {
|
|||
inject([AsyncTestCompleter], (async) => {
|
||||
registry.config(
|
||||
RootHostCmp,
|
||||
new AsyncRoute({path: '/first/...', loader: AsyncParentLoader, as: 'firstCmp'}));
|
||||
new AsyncRoute({path: '/first/...', loader: AsyncParentLoader, as: 'FirstCmp'}));
|
||||
|
||||
expect(() => registry.generate(['firstCmp', 'secondCmp'], RootHostCmp))
|
||||
.toThrowError('Could not find route named "secondCmp".');
|
||||
expect(() => registry.generate(['FirstCmp', 'SecondCmp'], RootHostCmp))
|
||||
.toThrowError('Could not find route named "SecondCmp".');
|
||||
|
||||
registry.recognize('/first/second', RootHostCmp)
|
||||
.then((_) => {
|
||||
expect(
|
||||
stringifyInstruction(registry.generate(['firstCmp', 'secondCmp'], RootHostCmp)))
|
||||
stringifyInstruction(registry.generate(['FirstCmp', 'SecondCmp'], RootHostCmp)))
|
||||
.toEqual('first/second');
|
||||
async.done();
|
||||
});
|
||||
|
@ -105,7 +105,7 @@ export function main() {
|
|||
|
||||
|
||||
it('should throw when generating a url and a parent has no config', () => {
|
||||
expect(() => registry.generate(['firstCmp', 'secondCmp'], RootHostCmp))
|
||||
expect(() => registry.generate(['FirstCmp', 'SecondCmp'], RootHostCmp))
|
||||
.toThrowError('Component "RootHostCmp" has no route config.');
|
||||
});
|
||||
|
||||
|
@ -233,9 +233,9 @@ export function main() {
|
|||
|
||||
it('should throw when linkParams are not terminal', () => {
|
||||
registry.config(RootHostCmp,
|
||||
new Route({path: '/first/...', component: DummyParentCmp, as: 'first'}));
|
||||
expect(() => { registry.generate(['first'], RootHostCmp); })
|
||||
.toThrowError('Link "["first"]" does not resolve to a terminal or async instruction.');
|
||||
new Route({path: '/first/...', component: DummyParentCmp, as: 'First'}));
|
||||
expect(() => { registry.generate(['First'], RootHostCmp); })
|
||||
.toThrowError('Link "["First"]" does not resolve to a terminal or async instruction.');
|
||||
});
|
||||
|
||||
it('should match matrix params on child components and query params on the root component',
|
||||
|
@ -256,13 +256,13 @@ export function main() {
|
|||
it('should generate URLs with matrix and query params', () => {
|
||||
registry.config(
|
||||
RootHostCmp,
|
||||
new Route({path: '/first/:param/...', component: DummyParentParamCmp, as: 'firstCmp'}));
|
||||
new Route({path: '/first/:param/...', component: DummyParentParamCmp, as: 'FirstCmp'}));
|
||||
|
||||
var url = stringifyInstruction(registry.generate(
|
||||
[
|
||||
'firstCmp',
|
||||
'FirstCmp',
|
||||
{param: 'one', query: 'cats'},
|
||||
'secondCmp',
|
||||
'SecondCmp',
|
||||
{
|
||||
param: 'two',
|
||||
sort: 'asc',
|
||||
|
@ -294,7 +294,7 @@ class DummyCmpB {}
|
|||
|
||||
@RouteConfig([
|
||||
new Redirect({path: '/', redirectTo: '/third'}),
|
||||
new Route({path: '/third', component: DummyCmpB, as: 'thirdCmp'})
|
||||
new Route({path: '/third', component: DummyCmpB, as: 'ThirdCmp'})
|
||||
])
|
||||
class DummyRedirectCmp {
|
||||
}
|
||||
|
@ -302,23 +302,23 @@ class DummyRedirectCmp {
|
|||
|
||||
@RouteConfig([
|
||||
new Redirect({path: '/', redirectTo: '/second'}),
|
||||
new Route({path: '/second/...', component: DummyRedirectCmp, as: 'secondCmp'})
|
||||
new Route({path: '/second/...', component: DummyRedirectCmp, as: 'SecondCmp'})
|
||||
])
|
||||
class DummyMultipleRedirectCmp {
|
||||
}
|
||||
|
||||
@RouteConfig([
|
||||
new Redirect({path: '/', redirectTo: '/second'}),
|
||||
new Route({path: '/second', component: DummyCmpB, as: 'secondCmp'})
|
||||
new Route({path: '/second', component: DummyCmpB, as: 'SecondCmp'})
|
||||
])
|
||||
class DummyParentRedirectCmp {
|
||||
}
|
||||
|
||||
@RouteConfig([new Route({path: '/second', component: DummyCmpB, as: 'secondCmp'})])
|
||||
@RouteConfig([new Route({path: '/second', component: DummyCmpB, as: 'SecondCmp'})])
|
||||
class DummyParentCmp {
|
||||
}
|
||||
|
||||
|
||||
@RouteConfig([new Route({path: '/second/:param', component: DummyCmpB, as: 'secondCmp'})])
|
||||
@RouteConfig([new Route({path: '/second/:param', component: DummyCmpB, as: 'SecondCmp'})])
|
||||
class DummyParentParamCmp {
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ class UserCmp {
|
|||
@View({
|
||||
template: `
|
||||
<div>
|
||||
<a [router-link]="['/detail']">detail view</a>
|
||||
<a [router-link]="['/Detail']">detail view</a>
|
||||
</div>`,
|
||||
directives: [RouterLink]
|
||||
})
|
||||
|
|
|
@ -120,9 +120,9 @@ export function main() {
|
|||
|
||||
|
||||
it('should throw when linkParams does not start with a "/" or "./"', () => {
|
||||
expect(() => router.generate(['firstCmp', 'secondCmp']))
|
||||
expect(() => router.generate(['FirstCmp', 'SecondCmp']))
|
||||
.toThrowError(
|
||||
`Link "${ListWrapper.toJSON(['firstCmp', 'secondCmp'])}" must start with "/", "./", or "../"`);
|
||||
`Link "${ListWrapper.toJSON(['FirstCmp', 'SecondCmp'])}" must start with "/", "./", or "../"`);
|
||||
});
|
||||
|
||||
|
||||
|
@ -141,12 +141,12 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should generate URLs from the root component when the path starts with /', () => {
|
||||
router.config([new Route({path: '/first/...', component: DummyParentComp, as: 'firstCmp'})]);
|
||||
router.config([new Route({path: '/first/...', component: DummyParentComp, as: 'FirstCmp'})]);
|
||||
|
||||
var instruction = router.generate(['/firstCmp', 'secondCmp']);
|
||||
var instruction = router.generate(['/FirstCmp', 'SecondCmp']);
|
||||
expect(stringifyInstruction(instruction)).toEqual('first/second');
|
||||
|
||||
instruction = router.generate(['/firstCmp/secondCmp']);
|
||||
instruction = router.generate(['/FirstCmp/SecondCmp']);
|
||||
expect(stringifyInstruction(instruction)).toEqual('first/second');
|
||||
});
|
||||
|
||||
|
@ -188,9 +188,9 @@ export function main() {
|
|||
describe('query string params', () => {
|
||||
it('should use query string params for the root route', () => {
|
||||
router.config(
|
||||
[new Route({path: '/hi/how/are/you', component: DummyComponent, as: 'greeting-url'})]);
|
||||
[new Route({path: '/hi/how/are/you', component: DummyComponent, as: 'GreetingUrl'})]);
|
||||
|
||||
var instruction = router.generate(['/greeting-url', {'name': 'brad'}]);
|
||||
var instruction = router.generate(['/GreetingUrl', {'name': 'brad'}]);
|
||||
var path = stringifyInstruction(instruction);
|
||||
expect(path).toEqual('hi/how/are/you?name=brad');
|
||||
});
|
||||
|
@ -198,9 +198,9 @@ export function main() {
|
|||
it('should serialize parameters that are not part of the route definition as query string params',
|
||||
() => {
|
||||
router.config(
|
||||
[new Route({path: '/one/two/:three', component: DummyComponent, as: 'number-url'})]);
|
||||
[new Route({path: '/one/two/:three', component: DummyComponent, as: 'NumberUrl'})]);
|
||||
|
||||
var instruction = router.generate(['/number-url', {'three': 'three', 'four': 'four'}]);
|
||||
var instruction = router.generate(['/NumberUrl', {'three': 'three', 'four': 'four'}]);
|
||||
var path = stringifyInstruction(instruction);
|
||||
expect(path).toEqual('one/two/three?four=four');
|
||||
});
|
||||
|
@ -209,20 +209,20 @@ export function main() {
|
|||
describe('matrix params', () => {
|
||||
it('should generate matrix params for each non-root component', () => {
|
||||
router.config(
|
||||
[new Route({path: '/first/...', component: DummyParentComp, as: 'firstCmp'})]);
|
||||
[new Route({path: '/first/...', component: DummyParentComp, as: 'FirstCmp'})]);
|
||||
|
||||
var instruction =
|
||||
router.generate(['/firstCmp', {'key': 'value'}, 'secondCmp', {'project': 'angular'}]);
|
||||
router.generate(['/FirstCmp', {'key': 'value'}, 'SecondCmp', {'project': 'angular'}]);
|
||||
var path = stringifyInstruction(instruction);
|
||||
expect(path).toEqual('first/second;project=angular?key=value');
|
||||
});
|
||||
|
||||
it('should work with named params', () => {
|
||||
router.config(
|
||||
[new Route({path: '/first/:token/...', component: DummyParentComp, as: 'firstCmp'})]);
|
||||
[new Route({path: '/first/:token/...', component: DummyParentComp, as: 'FirstCmp'})]);
|
||||
|
||||
var instruction =
|
||||
router.generate(['/firstCmp', {'token': 'min'}, 'secondCmp', {'author': 'max'}]);
|
||||
router.generate(['/FirstCmp', {'token': 'min'}, 'SecondCmp', {'author': 'max'}]);
|
||||
var path = stringifyInstruction(instruction);
|
||||
expect(path).toEqual('first/min/second;author=max');
|
||||
});
|
||||
|
@ -236,7 +236,7 @@ function loader(): Promise<Type> {
|
|||
|
||||
class DummyComponent {}
|
||||
|
||||
@RouteConfig([new Route({path: '/second', component: DummyComponent, as: 'secondCmp'})])
|
||||
@RouteConfig([new Route({path: '/second', component: DummyComponent, as: 'SecondCmp'})])
|
||||
class DummyParentComp {
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<ol class="inbox-list">
|
||||
<li *ng-for="#item of items" class="inbox-item-record">
|
||||
<a id="item-{{ item.id }}"
|
||||
[router-link]="['/detailPage', {'id':item.id}]">
|
||||
[router-link]="['/DetailPage', {'id':item.id}]">
|
||||
{{ item.subject }}</a>
|
||||
</li>
|
||||
</ol>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<inbox-side-menu class="inbox-aside">
|
||||
<a [router-link]="['/inbox']" class="link" [class.active]="inboxPageActive()">Inbox</a>
|
||||
<a [router-link]="['/drafts']" class="link" [class.active]="draftsPageActive()">Drafts</a>
|
||||
<a [router-link]="['/Inbox']" class="link" [class.active]="inboxPageActive()">Inbox</a>
|
||||
<a [router-link]="['/Drafts']" class="link" [class.active]="draftsPageActive()">Drafts</a>
|
||||
</inbox-side-menu>
|
||||
<router-outlet></router-outlet>
|
||||
|
|
|
@ -134,9 +134,9 @@ class DraftsCmp {
|
|||
@Component({selector: 'inbox-app', viewBindings: [DbService]})
|
||||
@View({templateUrl: "inbox-app.html", directives: [RouterOutlet, RouterLink]})
|
||||
@RouteConfig([
|
||||
new Route({path: '/', component: InboxCmp, as: 'inbox'}),
|
||||
new Route({path: '/drafts', component: DraftsCmp, as: 'drafts'}),
|
||||
new Route({path: '/detail/:id', component: InboxDetailCmp, as: 'detailPage'})
|
||||
new Route({path: '/', component: InboxCmp, as: 'Inbox'}),
|
||||
new Route({path: '/drafts', component: DraftsCmp, as: 'Drafts'}),
|
||||
new Route({path: '/detail/:id', component: InboxDetailCmp, as: 'DetailPage'})
|
||||
])
|
||||
export class InboxApp {
|
||||
router: Router;
|
||||
|
|
|
@ -13,6 +13,6 @@
|
|||
</p>
|
||||
|
||||
<span class="btn medium primary">
|
||||
<a [router-link]="record.draft ? ['../drafts'] : ['../inbox']" class="back-button">Back</a>
|
||||
<a [router-link]="record.draft ? ['../Drafts'] : ['../Inbox']" class="back-button">Back</a>
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<ol class="inbox-list">
|
||||
<li *ng-for="#item of items" class="inbox-item-record">
|
||||
<a id="item-{{ item.id }}"
|
||||
[router-link]="['/detailPage', {'id':item.id}]">{{ item.subject }}</a>
|
||||
[router-link]="['/DetailPage', {'id':item.id}]">{{ item.subject }}</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue