Skip to content

Commit 1bcca33

Browse files
committed
Added URL router on top
1 parent 1f2d3e4 commit 1bcca33

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/app/app.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
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 />
16
<loggedin-router-outlet>
27
</loggedin-router-outlet>

src/app/app.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,20 @@ import {LoggedInOutlet} from './LoggedInOutlet';
1414
})
1515
export class App {
1616
constructor(router: Router) {
17+
this.router = router;
1718
router
1819
.config('/home', Home)
1920
.then((_) => router.config('/login', Login, 'login'))
2021
.then((_) => router.config('/signup', Signup, 'signup'))
2122
.then((_) => router.navigate('/home'))
2223
}
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+
}
2333
}

0 commit comments

Comments
 (0)