Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.

Commit 80aa5d7

Browse files
committed
Added first book gui implementation.
1 parent 406104e commit 80aa5d7

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

app/bootstrap.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2
55
import {HTTP_PROVIDERS} from 'angular2/http';
66

77
// 3rd party libraries
8-
import {AuthHttp} from 'angular2-jwt/angular2-jwt';
8+
import {AuthHttp, AuthConfig} from 'angular2-jwt/angular2-jwt';
99

1010
// And application itself
1111
import {AppCmp} from './components/app/app';
@@ -14,7 +14,10 @@ import {AppCmp} from './components/app/app';
1414
bootstrap(AppCmp, [
1515
ROUTER_PROVIDERS, HTTP_PROVIDERS,
1616
provide(LocationStrategy, { useClass: HashLocationStrategy }),
17-
provide(AuthHttp, { useFactory: () => {
18-
return new AuthHttp();
19-
}})
17+
provide(AuthConfig, {
18+
useFactory: () => {
19+
return new AuthConfig();
20+
}
21+
}),
22+
AuthHttp
2023
]);
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
book list here
1+
book list here
2+
3+
<ul>
4+
<li *ngFor="#book of books">{{book.title}}</li>
5+
</ul>

app/components/examples/book/book.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,35 @@
1+
// Angular2 specified stuff
12
import {Component} from 'angular2/core';
3+
import {Headers} from 'angular2/http';
24

5+
// 3rd party libraries
6+
import {AuthHttp} from 'angular2-jwt/angular2-jwt';
7+
8+
// Component setup
39
@Component({
410
selector: 'book',
5-
templateUrl: './components/examples/book/book.html'
11+
templateUrl: './components/examples/book/book.html',
12+
providers: [AuthHttp]
613
})
714

8-
export class BookCmp {}
15+
// Actual component class
16+
export class BookCmp {
17+
books: any[];
18+
19+
private apiUrl = '<%= BACKEND_URL %>';
20+
21+
constructor(
22+
private _authHttp: AuthHttp
23+
) {
24+
let headers = new Headers();
25+
26+
headers.append('Content-Type', 'application/json');
27+
28+
this._authHttp.get(this.apiUrl + '/book?populate=author', {headers: headers})
29+
.subscribe(
30+
data => this.books = data.json(),
31+
err => console.log(err),
32+
() => console.log('Request Complete')
33+
);
34+
}
35+
}

0 commit comments

Comments
 (0)