This repository was archived by the owner on Oct 1, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
src/app/operators/components/operator Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 66 Inject ,
77 InjectionToken
88} from '@angular/core' ;
9- import { ActivatedRoute } from '@angular/router' ;
9+ import { Router , ActivatedRoute } from '@angular/router' ;
1010import { OperatorDoc } from '../../../../operator-docs/operator.model' ;
1111import 'rxjs/add/operator/pluck' ;
1212
@@ -24,18 +24,26 @@ export class OperatorComponent implements OnInit {
2424 private readonly baseSpecUrl = 'http://reactivex.io/rxjs/test-file/spec-js/operators' ;
2525
2626 constructor (
27+ private _router : Router ,
2728 private _activatedRoute : ActivatedRoute ,
2829 @Inject ( OPERATOR_TOKEN ) public operators : OperatorDoc [ ]
2930 ) { }
3031
3132 ngOnInit ( ) {
3233 this . _activatedRoute . params . pluck ( 'operator' ) . subscribe ( ( name : string ) => {
33- this . operator = this . operators . filter (
34- ( operator : OperatorDoc ) => operator . name === name
35- ) [ 0 ] ;
34+ this . operator =
35+ this . operators . filter (
36+ ( operator : OperatorDoc ) => operator . name === name
37+ ) [ 0 ] || this . notfound ( ) ;
3638 } ) ;
3739 }
3840
41+ notfound ( ) {
42+ console . log ( 'not found' ) ;
43+ this . _router . navigate ( [ '/operators' ] ) ;
44+ return { } ;
45+ }
46+
3947 get operatorName ( ) {
4048 return this . operator . name ;
4149 }
You can’t perform that action at this time.
0 commit comments