test(router): add a test checking that guards work for child routes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {Directive, HostBinding, HostListener, Input, OnChanges} from '@angular/core';
|
||||
import {LocationStrategy} from '@angular/common';
|
||||
import {Directive, HostBinding, HostListener, Input, OnChanges} from '@angular/core';
|
||||
|
||||
import {Router} from '../router';
|
||||
import {ActivatedRoute} from '../router_state';
|
||||
@@ -47,7 +47,9 @@ export class RouterLink implements OnChanges {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor(private router: Router, private route: ActivatedRoute, private locationStrategy: LocationStrategy) {}
|
||||
constructor(
|
||||
private router: Router, private route: ActivatedRoute,
|
||||
private locationStrategy: LocationStrategy) {}
|
||||
|
||||
@Input()
|
||||
set routerLink(data: any[]|string) {
|
||||
@@ -60,7 +62,7 @@ export class RouterLink implements OnChanges {
|
||||
|
||||
ngOnChanges(changes: {}): any { this.updateTargetUrlAndHref(); }
|
||||
|
||||
@HostListener("click", ["$event.button", "$event.ctrlKey", "$event.metaKey"])
|
||||
@HostListener('click', ['$event.button', '$event.ctrlKey', '$event.metaKey'])
|
||||
onClick(button: number, ctrlKey: boolean, metaKey: boolean): boolean {
|
||||
if (button !== 0 || ctrlKey || metaKey) {
|
||||
return true;
|
||||
|
||||
@@ -345,6 +345,7 @@ class GuardChecks {
|
||||
const currRoot = this.curr ? this.curr._root : null;
|
||||
this.traverseChildRoutes(futureRoot, currRoot, parentOutletMap);
|
||||
if (this.checks.length === 0) return of (true);
|
||||
|
||||
return Observable.from(this.checks)
|
||||
.map(s => {
|
||||
if (s instanceof CanActivate) {
|
||||
|
||||
Reference in New Issue
Block a user