diff --git a/modules/angular1_router/build.js b/modules/angular1_router/build.js index 9446a19f95..ba8f3d3447 100644 --- a/modules/angular1_router/build.js +++ b/modules/angular1_router/build.js @@ -78,7 +78,7 @@ function main() { "var router = new RootRouter(registry, undefined, location, new Object());", "$rootScope.$watch(function () { return $location.path(); }, function (path) {", "if (router.lastNavigationAttempt !== path) {", - "router.navigate(path);", + "router.navigateByUrl(path);", "}", "});", diff --git a/modules/angular1_router/index.html b/modules/angular1_router/index.html index 63dfbe65c3..28395c361e 100644 --- a/modules/angular1_router/index.html +++ b/modules/angular1_router/index.html @@ -14,7 +14,7 @@ angular.module('myApp', ['ngComponentRouter']) .controller('MyCtrl', ['$router', function ($router) { console.log($router); - $router.navigate('/') + $router.navigateByUrl('/') .then(console.log.bind(console, 'resolve'), console.log.bind(console, 'reject')); }]); diff --git a/modules/angular1_router/src/ng_outlet.js b/modules/angular1_router/src/ng_outlet.js index 92848f5339..071e443256 100644 --- a/modules/angular1_router/src/ng_outlet.js +++ b/modules/angular1_router/src/ng_outlet.js @@ -307,7 +307,7 @@ function anchorLinkDirective($router) { var href = element.attr(hrefAttrName); if (href && $router.recognize(href)) { - $router.navigate(href); + $router.navigateByUrl(href); event.preventDefault(); } }); diff --git a/modules/angular1_router/test/component_mapper_spec.js b/modules/angular1_router/test/component_mapper_spec.js index bfe9343b0f..8a8f5538bb 100644 --- a/modules/angular1_router/test/component_mapper_spec.js +++ b/modules/angular1_router/test/component_mapper_spec.js @@ -63,7 +63,7 @@ describe('$componentMapper', function () { { path: '/', component: Ctrl } ]); - $router.navigate('/'); + $router.navigateByUrl('/'); $rootScope.$digest(); expect(elt.text()).toBe('howdy'); diff --git a/modules/angular1_router/test/integration/lifecycle_hook_spec.js b/modules/angular1_router/test/integration/lifecycle_hook_spec.js index a6eccaaa25..3470d54b1b 100644 --- a/modules/angular1_router/test/integration/lifecycle_hook_spec.js +++ b/modules/angular1_router/test/integration/lifecycle_hook_spec.js @@ -51,7 +51,7 @@ describe('ngOutlet', function () { ]); compile('
outer {
}
'); - $router.navigate('/a'); + $router.navigateByUrl('/a'); $rootScope.$digest(); expect(spy).toHaveBeenCalled(); @@ -69,7 +69,7 @@ describe('ngOutlet', function () { ]); compile('
'); - $router.navigate('/user/brian'); + $router.navigateByUrl('/user/brian'); $rootScope.$digest(); expect(spy).toHaveBeenCalledWith(instructionFor(UserController), undefined); @@ -88,9 +88,9 @@ describe('ngOutlet', function () { ]); compile('
'); - $router.navigate('/user/brian'); + $router.navigateByUrl('/user/brian'); $rootScope.$digest(); - $router.navigate('/post/123'); + $router.navigateByUrl('/post/123'); $rootScope.$digest(); expect(spy).toHaveBeenCalledWith(instructionFor(activate), instructionFor(OneController)); @@ -108,7 +108,7 @@ describe('ngOutlet', function () { ]); compile('
'); - $router.navigate('/user'); + $router.navigateByUrl('/user'); $rootScope.$digest(); expect(injectedScope).toBeDefined(); @@ -127,9 +127,9 @@ describe('ngOutlet', function () { ]); compile('
'); - $router.navigate('/a'); + $router.navigateByUrl('/a'); $rootScope.$digest(); - $router.navigate('/b'); + $router.navigateByUrl('/b'); $rootScope.$digest(); expect(spy).toHaveBeenCalled(); }); @@ -147,9 +147,9 @@ describe('ngOutlet', function () { ]); compile('
'); - $router.navigate('/user/brian'); + $router.navigateByUrl('/user/brian'); $rootScope.$digest(); - $router.navigate('/post/123'); + $router.navigateByUrl('/post/123'); $rootScope.$digest(); expect(spy).toHaveBeenCalledWith(instructionFor(OneController), instructionFor(deactivate)); @@ -177,9 +177,9 @@ describe('ngOutlet', function () { ]); compile('outer {
}'); - $router.navigate('/a'); + $router.navigateByUrl('/a'); $rootScope.$digest(); - $router.navigate('/b'); + $router.navigateByUrl('/b'); $rootScope.$digest(); expect(log).toEqual(['deactivate', 'activate']); @@ -207,13 +207,13 @@ describe('ngOutlet', function () { ]); compile('outer {
}'); - $router.navigate('/on-reuse/1/a'); + $router.navigateByUrl('/on-reuse/1/a'); $rootScope.$digest(); expect(log).toEqual([]); expect(cmpInstanceCount).toBe(1); expect(elt.text()).toBe('outer { reuse {one} }'); - $router.navigate('/on-reuse/2/b'); + $router.navigateByUrl('/on-reuse/2/b'); $rootScope.$digest(); expect(log).toEqual(['reuse: on-reuse/1 -> on-reuse/2']); expect(cmpInstanceCount).toBe(1); @@ -242,13 +242,13 @@ describe('ngOutlet', function () { ]); compile('outer {
}'); - $router.navigate('/never-reuse/1/a'); + $router.navigateByUrl('/never-reuse/1/a'); $rootScope.$digest(); expect(log).toEqual([]); expect(cmpInstanceCount).toBe(1); expect(elt.text()).toBe('outer { reuse {one} }'); - $router.navigate('/never-reuse/2/b'); + $router.navigateByUrl('/never-reuse/2/b'); $rootScope.$digest(); expect(log).toEqual([]); expect(cmpInstanceCount).toBe(2); @@ -270,7 +270,7 @@ describe('ngOutlet', function () { ]); compile('outer {
}'); - $router.navigate('/a'); + $router.navigateByUrl('/a'); $rootScope.$digest(); expect(spy).not.toHaveBeenCalled(); @@ -292,7 +292,7 @@ describe('ngOutlet', function () { ]); compile('
'); - $router.navigate('/a'); + $router.navigateByUrl('/a'); $rootScope.$digest(); expect(spy).toHaveBeenCalled(); @@ -314,7 +314,7 @@ describe('ngOutlet', function () { ]); compile('
'); - $router.navigate('/a'); + $router.navigateByUrl('/a'); $rootScope.$digest(); expect(spy).toHaveBeenCalled(); @@ -335,7 +335,7 @@ describe('ngOutlet', function () { ]); compile('
'); - $router.navigate('/user/brian'); + $router.navigateByUrl('/user/brian'); $rootScope.$digest(); expect(spy).toHaveBeenCalledWith({name: 'brian'}, $http); })); @@ -354,11 +354,11 @@ describe('ngOutlet', function () { ]); compile('outer {
}'); - $router.navigate('/a'); + $router.navigateByUrl('/a'); $rootScope.$digest(); expect(elt.text()).toBe('outer { hi }'); - $router.navigate('/b'); + $router.navigateByUrl('/b'); $rootScope.$digest(); expect(elt.text()).toBe('outer { hi }'); }); @@ -377,11 +377,11 @@ describe('ngOutlet', function () { ]); compile('outer {
}'); - $router.navigate('/a'); + $router.navigateByUrl('/a'); $rootScope.$digest(); expect(elt.text()).toBe('outer { hi }'); - $router.navigate('/b'); + $router.navigateByUrl('/b'); $rootScope.$digest(); expect(elt.text()).toBe('outer { one }'); }); @@ -401,7 +401,7 @@ describe('ngOutlet', function () { ]); compile('
'); - $router.navigate('/a'); + $router.navigateByUrl('/a'); $rootScope.$digest(); expect(spy).toHaveBeenCalled(); @@ -421,9 +421,9 @@ describe('ngOutlet', function () { ]); compile('
'); - $router.navigate('/user/brian'); + $router.navigateByUrl('/user/brian'); $rootScope.$digest(); - $router.navigate('/post/123'); + $router.navigateByUrl('/post/123'); $rootScope.$digest(); expect(spy).toHaveBeenCalledWith(instructionFor(OneController), instructionFor(deactivate)); diff --git a/modules/angular1_router/test/integration/navigation_spec.js b/modules/angular1_router/test/integration/navigation_spec.js index 81dc00bb76..51632a11eb 100644 --- a/modules/angular1_router/test/integration/navigation_spec.js +++ b/modules/angular1_router/test/integration/navigation_spec.js @@ -43,7 +43,7 @@ describe('navigation', function () { { path: '/', component: OneController } ]); - $router.navigate('/'); + $router.navigateByUrl('/'); $rootScope.$digest(); expect(elt.text()).toBe('one'); @@ -59,7 +59,7 @@ describe('navigation', function () { spyOn(console, 'warn'); compile(''); - $router.navigate('/'); + $router.navigateByUrl('/'); expect(console.warn).toHaveBeenCalledWith('Could not find controller for', 'NoControllerController'); expect(elt.text()).toBe('4'); @@ -72,11 +72,11 @@ describe('navigation', function () { ]); compile(''); - $router.navigate('/user/brian'); + $router.navigateByUrl('/user/brian'); $rootScope.$digest(); expect(elt.text()).toBe('hello brian'); - $router.navigate('/user/igor'); + $router.navigateByUrl('/user/igor'); $rootScope.$digest(); expect(elt.text()).toBe('hello igor'); }); @@ -97,14 +97,14 @@ describe('navigation', function () { ]); compile(''); - $router.navigate('/parent/user/brian'); + $router.navigateByUrl('/parent/user/brian'); $rootScope.$digest(); expect(spy).toHaveBeenCalled(); expect(elt.text()).toBe('parent { hello brian }'); spy.calls.reset(); - $router.navigate('/parent/user/igor'); + $router.navigateByUrl('/parent/user/igor'); $rootScope.$digest(); expect(spy).not.toHaveBeenCalled(); expect(elt.text()).toBe('parent { hello igor }'); @@ -121,7 +121,7 @@ describe('navigation', function () { ]); compile('
outer {
}
'); - $router.navigate('/a/b'); + $router.navigateByUrl('/a/b'); $rootScope.$digest(); expect(elt.text()).toBe('outer { inner { one } }'); @@ -136,7 +136,7 @@ describe('navigation', function () { ]); compile('
root {
}
'); - $router.navigate('/'); + $router.navigateByUrl('/'); $rootScope.$digest(); expect(elt.text()).toBe('root { one }'); }); @@ -152,7 +152,7 @@ describe('navigation', function () { ]); compile('
'); - $router.navigate('/user'); + $router.navigateByUrl('/user'); $rootScope.$digest(); expect(injectedScope).toBeDefined(); @@ -166,7 +166,7 @@ describe('navigation', function () { compile('
'); - $router.navigate('/user'); + $router.navigateByUrl('/user'); $rootScope.$digest(); expect($location.path()).toBe('/user'); @@ -181,7 +181,7 @@ describe('navigation', function () { { path: '/user', component: UserController } ]); - $router.navigate('/'); + $router.navigateByUrl('/'); $rootScope.$digest(); expect($location.path()).toBe('/user'); @@ -203,13 +203,13 @@ describe('navigation', function () { compile('
'); - $router.navigate('/old-parent/old-child'); + $router.navigateByUrl('/old-parent/old-child'); $rootScope.$digest(); expect($location.path()).toBe('/new-parent/new-child'); expect(elt.text()).toBe('inner { one }'); - $router.navigate('/old-parent/old-child-two'); + $router.navigateByUrl('/old-parent/old-child-two'); $rootScope.$digest(); expect($location.path()).toBe('/new-parent/new-child-two'); @@ -243,7 +243,7 @@ describe('navigation', function () { ]); compile('
'); - $router.navigate('/pendingActivate'); + $router.navigateByUrl('/pendingActivate'); $rootScope.$digest(); expect($router.navigating).toBe(true); defer.resolve(); diff --git a/modules/angular1_router/test/ng_link_spec.js b/modules/angular1_router/test/ng_link_spec.js index a900a4dba5..2346da812b 100644 --- a/modules/angular1_router/test/ng_link_spec.js +++ b/modules/angular1_router/test/ng_link_spec.js @@ -42,7 +42,7 @@ describe('ngOutlet', function () { ]); compile('link | outer {
}'); - $router.navigate('/a'); + $router.navigateByUrl('/a'); $rootScope.$digest(); expect(elt.find('a').attr('href')).toBe('./b'); @@ -57,7 +57,7 @@ describe('ngOutlet', function () { ]); compile('outer {
}'); - $router.navigate('/a'); + $router.navigateByUrl('/a'); $rootScope.$digest(); expect(elt.find('a').attr('href')).toBe('./b'); @@ -74,7 +74,7 @@ describe('ngOutlet', function () { ]); compile('
'); - $router.navigate('/a'); + $router.navigateByUrl('/a'); $rootScope.$digest(); expect(elt.find('a').attr('href')).toBe('./b/lol'); @@ -91,7 +91,7 @@ describe('ngOutlet', function () { ]); compile('
'); - $router.navigate('/a'); + $router.navigateByUrl('/a'); $rootScope.$digest(); expect(elt.find('a').attr('href')).toBe('./b/one'); diff --git a/modules/angular1_router/test/ng_outlet_animation_spec.js b/modules/angular1_router/test/ng_outlet_animation_spec.js index dffd6581c3..ad60c74e32 100644 --- a/modules/angular1_router/test/ng_outlet_animation_spec.js +++ b/modules/angular1_router/test/ng_outlet_animation_spec.js @@ -46,7 +46,7 @@ describe('ngOutlet animations', function () { { path: '/user/:name', component: UserController } ]); - $router.navigate('/user/brian'); + $router.navigateByUrl('/user/brian'); $rootScope.$digest(); expect(elt.text()).toBe('hello brian'); @@ -55,7 +55,7 @@ describe('ngOutlet animations', function () { expect(item.event).toBe('enter'); // navigate to pete - $router.navigate('/user/pete'); + $router.navigateByUrl('/user/pete'); $rootScope.$digest(); expect(elt.text()).toBe('hello pete'); diff --git a/modules/angular2/src/router/router.ts b/modules/angular2/src/router/router.ts index 4abba0c9f1..5fbf2ebed6 100644 --- a/modules/angular2/src/router/router.ts +++ b/modules/angular2/src/router/router.ts @@ -159,7 +159,7 @@ export class Router { * If the given URL begins with a `/`, router will navigate absolutely. * If the given URL does not begin with `/`, the router will navigate relative to this component. */ - navigate(url: string, _skipLocationChange: boolean = false): Promise { + navigateByUrl(url: string, _skipLocationChange: boolean = false): Promise { return this._currentNavigation = this._currentNavigation.then((_) => { this.lastNavigationAttempt = url; this._startNavigating(); @@ -177,8 +177,8 @@ export class Router { * Navigate via the provided instruction. Returns a promise that resolves when navigation is * complete. */ - navigateInstruction(instruction: Instruction, - _skipLocationChange: boolean = false): Promise { + navigateByInstruction(instruction: Instruction, + _skipLocationChange: boolean = false): Promise { if (isBlank(instruction)) { return _resolveToFalse; } @@ -373,7 +373,7 @@ export class Router { if (isBlank(this.lastNavigationAttempt)) { return this._currentNavigation; } - return this.navigate(this.lastNavigationAttempt); + return this.navigateByUrl(this.lastNavigationAttempt); } @@ -445,10 +445,11 @@ export class RootRouter extends Router { hostComponent: Type) { super(registry, pipeline, null, hostComponent); this._location = location; - this._location.subscribe((change) => this.navigate(change['url'], isPresent(change['pop']))); + this._location.subscribe((change) => + this.navigateByUrl(change['url'], isPresent(change['pop']))); this.registry.configFromComponent(hostComponent); - this.navigate(location.path()); + this.navigateByUrl(location.path()); } commit(instruction: Instruction, _skipLocationChange: boolean = false): Promise { @@ -471,15 +472,15 @@ class ChildRouter extends Router { } - navigate(url: string, _skipLocationChange: boolean = false): Promise { + navigateByUrl(url: string, _skipLocationChange: boolean = false): Promise { // Delegate navigation to the root router - return this.parent.navigate(url, _skipLocationChange); + return this.parent.navigateByUrl(url, _skipLocationChange); } - navigateInstruction(instruction: Instruction, - _skipLocationChange: boolean = false): Promise { + navigateByInstruction(instruction: Instruction, + _skipLocationChange: boolean = false): Promise { // Delegate navigation to the root router - return this.parent.navigateInstruction(instruction, _skipLocationChange); + return this.parent.navigateByInstruction(instruction, _skipLocationChange); } } diff --git a/modules/angular2/src/router/router_link.ts b/modules/angular2/src/router/router_link.ts index f5654e70de..76c5b11b7b 100644 --- a/modules/angular2/src/router/router_link.ts +++ b/modules/angular2/src/router/router_link.ts @@ -66,7 +66,7 @@ export class RouterLink { } onClick(): boolean { - this._router.navigateInstruction(this._navigationInstruction); + this._router.navigateByInstruction(this._navigationInstruction); return false; } } diff --git a/modules/angular2/test/router/integration/lifecycle_hook_spec.ts b/modules/angular2/test/router/integration/lifecycle_hook_spec.ts index c04f390d54..dbc6c01ba3 100644 --- a/modules/angular2/test/router/integration/lifecycle_hook_spec.ts +++ b/modules/angular2/test/router/integration/lifecycle_hook_spec.ts @@ -91,7 +91,7 @@ export function main() { it('should call the onActivate hook', inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) - .then((_) => rtr.navigate('/on-activate')) + .then((_) => rtr.navigateByUrl('/on-activate')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('activate cmp'); @@ -110,7 +110,7 @@ export function main() { completer.resolve(true); } }); - rtr.navigate('/parent-activate/child-activate') + rtr.navigateByUrl('/parent-activate/child-activate') .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('parent {activate cmp}'); @@ -126,8 +126,8 @@ export function main() { it('should call the onDeactivate hook', inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) - .then((_) => rtr.navigate('/on-deactivate')) - .then((_) => rtr.navigate('/a')) + .then((_) => rtr.navigateByUrl('/on-deactivate')) + .then((_) => rtr.navigateByUrl('/a')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('A'); @@ -140,7 +140,7 @@ export function main() { inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) - .then((_) => rtr.navigate('/parent-deactivate/child-deactivate')) + .then((_) => rtr.navigateByUrl('/parent-deactivate/child-deactivate')) .then((_) => { ObservableWrapper.subscribe(eventBus, (ev) => { if (ev.startsWith('deactivate')) { @@ -149,7 +149,7 @@ export function main() { expect(rootTC.nativeElement).toHaveText('parent {deactivate cmp}'); } }); - rtr.navigate('/a').then((_) => { + rtr.navigateByUrl('/a').then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('A'); expect(log).toEqual([ @@ -165,14 +165,14 @@ export function main() { inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) - .then((_) => rtr.navigate('/on-reuse/1/a')) + .then((_) => rtr.navigateByUrl('/on-reuse/1/a')) .then((_) => { rootTC.detectChanges(); expect(log).toEqual([]); expect(rootTC.nativeElement).toHaveText('reuse {A}'); expect(cmpInstanceCount).toBe(1); }) - .then((_) => rtr.navigate('/on-reuse/2/b')) + .then((_) => rtr.navigateByUrl('/on-reuse/2/b')) .then((_) => { rootTC.detectChanges(); expect(log).toEqual(['reuse: /on-reuse/1 -> /on-reuse/2']); @@ -187,14 +187,14 @@ export function main() { inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) - .then((_) => rtr.navigate('/never-reuse/1/a')) + .then((_) => rtr.navigateByUrl('/never-reuse/1/a')) .then((_) => { rootTC.detectChanges(); expect(log).toEqual([]); expect(rootTC.nativeElement).toHaveText('reuse {A}'); expect(cmpInstanceCount).toBe(1); }) - .then((_) => rtr.navigate('/never-reuse/2/b')) + .then((_) => rtr.navigateByUrl('/never-reuse/2/b')) .then((_) => { rootTC.detectChanges(); expect(log).toEqual([]); @@ -214,7 +214,7 @@ export function main() { completer.resolve(true); } }); - rtr.navigate('/can-activate/a') + rtr.navigateByUrl('/can-activate/a') .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('canActivate {A}'); @@ -234,7 +234,7 @@ export function main() { completer.resolve(false); } }); - rtr.navigate('/can-activate/a') + rtr.navigateByUrl('/can-activate/a') .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText(''); @@ -248,7 +248,7 @@ export function main() { inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) - .then((_) => rtr.navigate('/can-deactivate/a')) + .then((_) => rtr.navigateByUrl('/can-deactivate/a')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('canDeactivate {A}'); @@ -260,7 +260,7 @@ export function main() { } }); - rtr.navigate('/a').then((_) => { + rtr.navigateByUrl('/a').then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('A'); expect(log).toEqual(['canDeactivate: /can-deactivate -> /a']); @@ -273,7 +273,7 @@ export function main() { inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) - .then((_) => rtr.navigate('/can-deactivate/a')) + .then((_) => rtr.navigateByUrl('/can-deactivate/a')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('canDeactivate {A}'); @@ -285,7 +285,7 @@ export function main() { } }); - rtr.navigate('/a').then((_) => { + rtr.navigateByUrl('/a').then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('canDeactivate {A}'); expect(log).toEqual(['canDeactivate: /can-deactivate -> /a']); @@ -299,7 +299,7 @@ export function main() { inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) - .then((_) => rtr.navigate('/activation-hooks/child')) + .then((_) => rtr.navigateByUrl('/activation-hooks/child')) .then((_) => { expect(log).toEqual([ 'canActivate child: null -> /child', @@ -309,7 +309,7 @@ export function main() { ]); log = []; - return rtr.navigate('/a'); + return rtr.navigateByUrl('/a'); }) .then((_) => { expect(log).toEqual([ @@ -325,7 +325,7 @@ export function main() { it('should only run reuse hooks when reusing', inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) - .then((_) => rtr.navigate('/reuse-hooks/1')) + .then((_) => rtr.navigateByUrl('/reuse-hooks/1')) .then((_) => { expect(log).toEqual( ['canActivate: null -> /reuse-hooks/1', 'onActivate: null -> /reuse-hooks/1']); @@ -338,7 +338,7 @@ export function main() { log = []; - return rtr.navigate('/reuse-hooks/2'); + return rtr.navigateByUrl('/reuse-hooks/2'); }) .then((_) => { expect(log).toEqual([ @@ -352,7 +352,7 @@ export function main() { it('should not run reuse hooks when not reusing', inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) - .then((_) => rtr.navigate('/reuse-hooks/1')) + .then((_) => rtr.navigateByUrl('/reuse-hooks/1')) .then((_) => { expect(log).toEqual( ['canActivate: null -> /reuse-hooks/1', 'onActivate: null -> /reuse-hooks/1']); @@ -364,7 +364,7 @@ export function main() { }); log = []; - return rtr.navigate('/reuse-hooks/2'); + return rtr.navigateByUrl('/reuse-hooks/2'); }) .then((_) => { expect(log).toEqual([ diff --git a/modules/angular2/test/router/integration/navigation_spec.ts b/modules/angular2/test/router/integration/navigation_spec.ts index 6268dbff7f..6d72c43610 100644 --- a/modules/angular2/test/router/integration/navigation_spec.ts +++ b/modules/angular2/test/router/integration/navigation_spec.ts @@ -75,7 +75,7 @@ export function main() { it('should work in a simple case', inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})])) - .then((_) => rtr.navigate('/test')) + .then((_) => rtr.navigateByUrl('/test')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('hello'); @@ -88,12 +88,12 @@ export function main() { inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/user/:name', component: UserCmp})])) - .then((_) => rtr.navigate('/user/brian')) + .then((_) => rtr.navigateByUrl('/user/brian')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('hello brian'); }) - .then((_) => rtr.navigate('/user/igor')) + .then((_) => rtr.navigateByUrl('/user/igor')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('hello igor'); @@ -105,7 +105,7 @@ export function main() { it('should navigate to child routes', inject([AsyncTestCompleter], (async) => { compile('outer { }') .then((_) => rtr.config([new Route({path: '/a/...', component: ParentCmp})])) - .then((_) => rtr.navigate('/a/b')) + .then((_) => rtr.navigateByUrl('/a/b')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('outer { inner { hello } }'); @@ -117,7 +117,7 @@ export function main() { it('should navigate to child routes of async routes', inject([AsyncTestCompleter], (async) => { compile('outer { }') .then((_) => rtr.config([new AsyncRoute({path: '/a/...', loader: parentLoader})])) - .then((_) => rtr.navigate('/a/b')) + .then((_) => rtr.navigateByUrl('/a/b')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('outer { inner { hello } }'); @@ -133,7 +133,7 @@ export function main() { new Redirect({path: '/original', redirectTo: '/redirected'}), new Route({path: '/redirected', component: HelloCmp}) ])) - .then((_) => rtr.navigate('/original')) + .then((_) => rtr.navigateByUrl('/original')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('hello'); @@ -146,13 +146,13 @@ export function main() { it('should reuse common parent components', inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/team/:id/...', component: TeamCmp})])) - .then((_) => rtr.navigate('/team/angular/user/rado')) + .then((_) => rtr.navigateByUrl('/team/angular/user/rado')) .then((_) => { rootTC.detectChanges(); expect(cmpInstanceCount).toBe(1); expect(rootTC.nativeElement).toHaveText('team angular { hello rado }'); }) - .then((_) => rtr.navigate('/team/angular/user/victor')) + .then((_) => rtr.navigateByUrl('/team/angular/user/victor')) .then((_) => { rootTC.detectChanges(); expect(cmpInstanceCount).toBe(1); @@ -165,14 +165,14 @@ export function main() { inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/team/:id/...', component: TeamCmp})])) - .then((_) => rtr.navigate('/team/angular/user/rado')) + .then((_) => rtr.navigateByUrl('/team/angular/user/rado')) .then((_) => { rootTC.detectChanges(); expect(cmpInstanceCount).toBe(1); expect(childCmpInstanceCount).toBe(1); expect(rootTC.nativeElement).toHaveText('team angular { hello rado }'); }) - .then((_) => rtr.navigate('/team/dart/user/rado')) + .then((_) => rtr.navigateByUrl('/team/dart/user/rado')) .then((_) => { rootTC.detectChanges(); expect(cmpInstanceCount).toBe(2); @@ -187,7 +187,7 @@ export function main() { .then((_) => rtr.config([ new Route({path: '/route-data', component: RouteDataCmp, data: {'isAdmin': true}}) ])) - .then((_) => rtr.navigate('/route-data')) + .then((_) => rtr.navigateByUrl('/route-data')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText(Json.stringify({'isAdmin': true})); @@ -202,7 +202,7 @@ export function main() { new AsyncRoute( {path: '/route-data', loader: AsyncRouteDataCmp, data: {isAdmin: true}}) ])) - .then((_) => rtr.navigate('/route-data')) + .then((_) => rtr.navigateByUrl('/route-data')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText(Json.stringify({'isAdmin': true})); @@ -215,7 +215,7 @@ export function main() { compile() .then((_) => rtr.config( [new Route({path: '/route-data-default', component: RouteDataCmp})])) - .then((_) => rtr.navigate('/route-data-default')) + .then((_) => rtr.navigateByUrl('/route-data-default')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('null'); @@ -228,7 +228,7 @@ export function main() { .then((_) => rtr.config([ new Route({path: '/route-data-array', component: RouteDataCmp, data: [1, 2, 3]}) ])) - .then((_) => rtr.navigate('/route-data-array')) + .then((_) => rtr.navigateByUrl('/route-data-array')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText(Json.stringify([1, 2, 3])); @@ -242,7 +242,7 @@ export function main() { new Route( {path: '/route-data-string', component: RouteDataCmp, data: 'hello world'}) ])) - .then((_) => rtr.navigate('/route-data-string')) + .then((_) => rtr.navigateByUrl('/route-data-string')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText(Json.stringify('hello world')); @@ -254,7 +254,7 @@ export function main() { it('should recognize a simple case', inject([AsyncTestCompleter], (async) => { compile() .then((_) => rtr.config([new Route({path: '/...', component: AuxCmp})])) - .then((_) => rtr.navigate('/hello(modal)')) + .then((_) => rtr.navigateByUrl('/hello(modal)')) .then((_) => { rootTC.detectChanges(); expect(rootTC.nativeElement).toHaveText('main {hello} | aux {modal}'); diff --git a/modules/angular2/test/router/integration/router_integration_spec.ts b/modules/angular2/test/router/integration/router_integration_spec.ts index 5e735f3b4a..2e2a807a74 100644 --- a/modules/angular2/test/router/integration/router_integration_spec.ts +++ b/modules/angular2/test/router/integration/router_integration_spec.ts @@ -72,7 +72,7 @@ export function main() { inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => { tcb.createAsync(AppCmp).then((rootTC) => { var router = rootTC.componentInstance.router; - PromiseWrapper.catchError(router.navigate('/cause-error'), (error) => { + PromiseWrapper.catchError(router.navigateByUrl('/cause-error'), (error) => { expect(rootTC.nativeElement).toHaveText('outer { oh no }'); expect(error).toContainError('oops!'); async.done(); @@ -123,11 +123,11 @@ export function main() { if (flipped) { location.back(); } else { - router.navigate(nextUrl); + router.navigateByUrl(nextUrl); } }); - router.navigate(history[0][0]); + router.navigateByUrl(history[0][0]); }); }), 1000); }); @@ -146,7 +146,7 @@ export function main() { expect(rootTC.componentInstance.location.path()).toEqual('/parent/child'); async.done(); }); - router.navigate('/parent/child'); + router.navigateByUrl('/parent/child'); }); }), 1000); @@ -165,7 +165,7 @@ export function main() { .toEqual('/my/app/parent/child'); async.done(); }); - router.navigate('/parent/child'); + router.navigateByUrl('/parent/child'); }); }), 1000); @@ -190,7 +190,7 @@ export function main() { .toEqual('/qs?q=search-for-something');*/ async.done(); }); - router.navigate('/qs?q=search-for-something'); + router.navigateByUrl('/qs?q=search-for-something'); rootTC.detectChanges(); }); }), 1000); diff --git a/modules/angular2/test/router/integration/router_link_spec.ts b/modules/angular2/test/router/integration/router_link_spec.ts index e997065d95..f5f0684af7 100644 --- a/modules/angular2/test/router/integration/router_link_spec.ts +++ b/modules/angular2/test/router/integration/router_link_spec.ts @@ -76,7 +76,7 @@ export function main() { compile('') .then((_) => router.config([new Route({path: '/user', component: UserCmp, as: 'user'})])) - .then((_) => router.navigate('/a/b')) + .then((_) => router.navigateByUrl('/a/b')) .then((_) => { rootTC.detectChanges(); expect(getHref(rootTC)).toEqual('/my/base/user'); @@ -89,7 +89,7 @@ export function main() { compile('') .then((_) => router.config([new Route({path: '/user', component: UserCmp, as: 'user'})])) - .then((_) => router.navigate('/a/b')) + .then((_) => router.navigateByUrl('/a/b')) .then((_) => { rootTC.detectChanges(); expect(getHref(rootTC)).toEqual('/user'); @@ -102,7 +102,7 @@ export function main() { compile('{{name}}') .then((_) => router.config( [new Route({path: '/user/:name', component: UserCmp, as: 'user'})])) - .then((_) => router.navigate('/a/b')) + .then((_) => router.navigateByUrl('/a/b')) .then((_) => { rootTC.componentInstance.name = 'brian'; rootTC.detectChanges(); @@ -118,7 +118,7 @@ export function main() { compile() .then((_) => router.config( [new Route({path: '/page/:number', component: SiblingPageCmp, as: 'page'})])) - .then((_) => router.navigate('/page/1')) + .then((_) => router.navigateByUrl('/page/1')) .then((_) => { rootTC.detectChanges(); expect(DOM.getAttribute( @@ -159,7 +159,7 @@ export function main() { compile() .then((_) => router.config( [new Route({path: '/book/:title/...', component: BookCmp, as: 'book'})])) - .then((_) => router.navigate('/book/1984/page/1')) + .then((_) => router.navigateByUrl('/book/1984/page/1')) .then((_) => { rootTC.detectChanges(); expect(DOM.getAttribute( @@ -206,7 +206,7 @@ export function main() { async.done(); }); - router.navigate('/better-child'); + router.navigateByUrl('/better-child'); }); })); @@ -247,7 +247,7 @@ export function main() { async.done(); }); - router.navigate('/child-with-grandchild/grandchild'); + router.navigateByUrl('/child-with-grandchild/grandchild'); }); })); }); @@ -265,7 +265,7 @@ export function main() { compile('') .then((_) => router.config( [new Route({path: '/user', component: UserCmp, as: 'user'})])) - .then((_) => router.navigate('/a/b')) + .then((_) => router.navigateByUrl('/a/b')) .then((_) => { rootTC.detectChanges(); @@ -286,7 +286,7 @@ export function main() { compile('') .then((_) => router.config( [new Route({path: '/user', component: UserCmp, as: 'user'})])) - .then((_) => router.navigate('/a/b')) + .then((_) => router.navigateByUrl('/a/b')) .then((_) => { rootTC.detectChanges(); diff --git a/modules/angular2/test/router/route_config_spec.ts b/modules/angular2/test/router/route_config_spec.ts index a43b25c2e9..91c8947f91 100644 --- a/modules/angular2/test/router/route_config_spec.ts +++ b/modules/angular2/test/router/route_config_spec.ts @@ -64,7 +64,7 @@ export function main() { expect(applicationRef.hostComponent.location.path()).toEqual('/parent/child'); async.done(); }); - router.navigate('/parent/child'); + router.navigateByUrl('/parent/child'); }); }), 1000); @@ -78,7 +78,7 @@ export function main() { expect(applicationRef.hostComponent.location.path()).toEqual('/after'); async.done(); }); - router.navigate('/before'); + router.navigateByUrl('/before'); }); }), 1000); @@ -92,7 +92,7 @@ export function main() { expect(applicationRef.hostComponent.location.path()).toEqual('/hello'); async.done(); }); - router.navigate('/hello'); + router.navigateByUrl('/hello'); }); }), 1000); @@ -107,7 +107,7 @@ export function main() { expect(applicationRef.hostComponent.location.path()).toEqual('/hello'); async.done(); }); - router.navigate('/hello'); + router.navigateByUrl('/hello'); }); }), 1000); diff --git a/modules/angular2/test/router/router_link_spec.ts b/modules/angular2/test/router/router_link_spec.ts index bbb86323f3..ee2f5a9fbe 100644 --- a/modules/angular2/test/router/router_link_spec.ts +++ b/modules/angular2/test/router/router_link_spec.ts @@ -66,7 +66,7 @@ export function main() { testComponent.detectChanges(); // TODO: shouldn't this be just 'click' rather than '^click'? testComponent.query(By.css('a')).triggerEventHandler('click', null); - expect(router.spy('navigateInstruction')).toHaveBeenCalledWith(dummyInstruction); + expect(router.spy('navigateByInstruction')).toHaveBeenCalledWith(dummyInstruction); async.done(); }); })); diff --git a/modules/angular2/test/router/router_spec.ts b/modules/angular2/test/router/router_spec.ts index 765aed00d7..06301b9426 100644 --- a/modules/angular2/test/router/router_spec.ts +++ b/modules/angular2/test/router/router_spec.ts @@ -68,7 +68,7 @@ export function main() { router.registerPrimaryOutlet(outlet) .then((_) => router.config([new Route({path: '/a', component: DummyComponent})])) - .then((_) => router.navigate('/a')) + .then((_) => router.navigateByUrl('/a')) .then((_) => { expect(outlet.spy('activate')).toHaveBeenCalled(); expect(location.urlChanges).toEqual(['/a']); @@ -82,7 +82,7 @@ export function main() { router.registerPrimaryOutlet(outlet) .then((_) => router.config([new Route({path: '/b', component: DummyComponent})])) - .then((_) => router.navigate('/b', true)) + .then((_) => router.navigateByUrl('/b', true)) .then((_) => { expect(outlet.spy('activate')).toHaveBeenCalled(); expect(location.urlChanges).toEqual([]); @@ -95,7 +95,7 @@ export function main() { var outlet = makeDummyOutlet(); router.registerPrimaryOutlet(outlet) - .then((_) => router.navigate('/a')) + .then((_) => router.navigateByUrl('/a')) .then((_) => { expect(outlet.spy('activate')).not.toHaveBeenCalled(); return router.config([new Route({path: '/a', component: DummyComponent})]); @@ -146,7 +146,7 @@ export function main() { router.config([new AsyncRoute({path: '/first', loader: loader, as: 'FirstCmp'})]); var instruction = router.generate(['/FirstCmp']); - router.navigateInstruction(instruction) + router.navigateByInstruction(instruction) .then((_) => { expect(outlet.spy('activate')).toHaveBeenCalled(); async.done(); @@ -162,7 +162,7 @@ export function main() { new Route({path: '/a', component: DummyComponent, as: 'A'}), new Route({path: '/b', component: DummyComponent, as: 'B'}) ])) - .then((_) => router.navigate('/a')) + .then((_) => router.navigateByUrl('/a')) .then((_) => { var instruction = router.generate(['/A']); var otherInstruction = router.generate(['/B']);