File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change
1
+ < form role ="form " (submit) ="goTo($event, url.value) ">
2
+ < input style ="display: inline;width: 80%; margin-right: 10px " type ="text " #url class ="form-control " id ="password " placeholder ="Enter the URL to go to ">
3
+ < button type ="submit " class ="btn btn-default "> Go</ button >
4
+ </ form >
5
+ < br />
1
6
< loggedin-router-outlet >
2
7
</ loggedin-router-outlet >
Original file line number Diff line number Diff line change @@ -14,10 +14,20 @@ import {LoggedInOutlet} from './LoggedInOutlet';
14
14
} )
15
15
export class App {
16
16
constructor ( router : Router ) {
17
+ this . router = router ;
17
18
router
18
19
. config ( '/home' , Home )
19
20
. then ( ( _ ) => router . config ( '/login' , Login , 'login' ) )
20
21
. then ( ( _ ) => router . config ( '/signup' , Signup , 'signup' ) )
21
22
. then ( ( _ ) => router . navigate ( '/home' ) )
22
23
}
24
+
25
+ goTo ( event , url ) {
26
+ event . preventDefault ( ) ;
27
+ this . router . navigate ( url ) . then ( ( ) => {
28
+ console . log ( "Router successfully to" , url ) ;
29
+ } , ( ) => {
30
+ console . log ( "Error going to URL" , url ) ;
31
+ } ) ;
32
+ }
23
33
}
You can’t perform that action at this time.
0 commit comments