@@ -56,65 +56,69 @@ export class NSRouterLink implements OnChanges { // tslint:disable-line:directiv
56
56
private route : ActivatedRoute ,
57
57
@Optional ( ) private pageRoute : PageRoute ) {
58
58
59
- this . usePageRoute = ( this . pageRoute && this . route === this . pageRoute . activatedRoute . getValue ( ) ) ;
60
- }
59
+ this . usePageRoute = ( this . pageRoute && this . route === this . pageRoute . activatedRoute . getValue ( ) ) ;
60
+ }
61
61
62
- @Input ( "nsRouterLink" )
63
- set params ( data : any [ ] | string ) {
64
- if ( Array . isArray ( data ) ) {
65
- this . commands = data ;
66
- } else {
67
- this . commands = [ data ] ;
68
- }
62
+ @Input ( "nsRouterLink" )
63
+ set params ( data : any [ ] | string ) {
64
+ if ( Array . isArray ( data ) ) {
65
+ this . commands = data ;
66
+ } else {
67
+ this . commands = [ data ] ;
69
68
}
69
+ }
70
70
71
71
72
- @HostListener ( "tap" )
73
- onTap ( ) {
74
- routerLog ( "nsRouterLink.tapped: " + this . commands + " usePageRoute: " +
75
- this . usePageRoute + " clearHistory: " + this . clearHistory + " transition: " +
76
- JSON . stringify ( this . pageTransition ) ) ;
72
+ @HostListener ( "tap" )
73
+ onTap ( ) {
74
+ routerLog ( "nsRouterLink.tapped: " + this . commands + " usePageRoute: " +
75
+ this . usePageRoute + " clearHistory: " + this . clearHistory + " transition: " +
76
+ JSON . stringify ( this . pageTransition ) ) ;
77
77
78
- const extras = this . getExtras ( ) ;
79
- this . navigator . navigateByUrl ( this . urlTree , extras ) ;
80
- }
78
+ const extras = this . getExtras ( ) ;
79
+ this . navigator . navigateByUrl ( this . urlTree , extras ) ;
80
+ }
81
81
82
- private getExtras ( ) : NavigationExtras & NavigationOptions {
83
- const transition = this . getTransition ( ) ;
84
- return {
85
- queryParams : this . queryParams ,
86
- fragment : this . fragment ,
87
- clearHistory : this . clearHistory ,
88
- animated : transition . animated ,
89
- transition : transition . transition ,
90
- relativeTo : this . currentRoute ,
91
- } ;
92
- }
82
+ private getExtras ( ) : NavigationExtras & NavigationOptions {
83
+ const transition = this . getTransition ( ) ;
84
+ return {
85
+ queryParams : this . queryParams ,
86
+ fragment : this . fragment ,
87
+ clearHistory : this . convertClearHistory ( this . clearHistory ) ,
88
+ animated : transition . animated ,
89
+ transition : transition . transition ,
90
+ relativeTo : this . currentRoute ,
91
+ } ;
92
+ }
93
+
94
+ private convertClearHistory ( value : boolean | string ) : boolean {
95
+ return value === true || value === "true" ;
96
+ }
93
97
94
- private getTransition ( ) : { animated : boolean , transition ?: NavigationTransition } {
95
- if ( typeof this . pageTransition === "boolean" ) {
96
- return { animated : < boolean > this . pageTransition } ;
97
- } else if ( isString ( this . pageTransition ) ) {
98
- if ( this . pageTransition === "none" || this . pageTransition === "false" ) {
99
- return { animated : false } ;
100
- } else {
101
- return { animated : true , transition : { name : < string > this . pageTransition } } ;
102
- }
98
+ private getTransition ( ) : { animated : boolean , transition ?: NavigationTransition } {
99
+ if ( typeof this . pageTransition === "boolean" ) {
100
+ return { animated : < boolean > this . pageTransition } ;
101
+ } else if ( isString ( this . pageTransition ) ) {
102
+ if ( this . pageTransition === "none" || this . pageTransition === "false" ) {
103
+ return { animated : false } ;
103
104
} else {
104
- return {
105
- animated : true ,
106
- transition : this . pageTransition
107
- } ;
105
+ return { animated : true , transition : { name : < string > this . pageTransition } } ;
108
106
}
107
+ } else {
108
+ return {
109
+ animated : true ,
110
+ transition : this . pageTransition
111
+ } ;
109
112
}
113
+ }
110
114
111
- ngOnChanges ( _ : { } ) : any {
112
- this . updateUrlTree ( ) ;
113
- }
115
+ ngOnChanges ( _ : { } ) : any {
116
+ this . updateUrlTree ( ) ;
117
+ }
114
118
115
- private updateUrlTree ( ) : void {
116
- this . urlTree = this . router . createUrlTree (
117
- this . commands ,
118
- { relativeTo : this . currentRoute , queryParams : this . queryParams , fragment : this . fragment } ) ;
119
- }
119
+ private updateUrlTree ( ) : void {
120
+ this . urlTree = this . router . createUrlTree (
121
+ this . commands ,
122
+ { relativeTo : this . currentRoute , queryParams : this . queryParams , fragment : this . fragment } ) ;
123
+ }
120
124
}
0 commit comments