Skip to content

Commit 105528b

Browse files
author
Dave Syer
committed
Add http backend data
1 parent 68e9075 commit 105528b

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

src/main/client/src/app/app.component.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
<h1>
44
Welcome {{title}}!
55
</h1>
6+
<div class="container">
7+
<p>ID: <span>{{data.id}}</span></p>
8+
<p>Message: <span>{{data.content}}</span></p>
9+
</div>
610
</div>
711

src/main/client/src/app/app.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component } from '@angular/core';
2+
import {HttpClient} from '@angular/common/http';
23

34
@Component({
45
selector: 'app-root',
@@ -7,4 +8,8 @@ import { Component } from '@angular/core';
78
})
89
export class AppComponent {
910
title = 'app';
11+
data = {};
12+
constructor(private http: HttpClient) {
13+
http.get('resource').subscribe(data => {this.data = data;});
14+
}
1015
}

src/main/client/src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import { BrowserModule } from '@angular/platform-browser';
22
import { NgModule } from '@angular/core';
33

44
import { AppComponent } from './app.component';
5+
import { HttpClientModule } from '@angular/common/http';
56

67
@NgModule({
78
declarations: [
89
AppComponent
910
],
1011
imports: [
11-
BrowserModule
12+
BrowserModule,
13+
HttpClientModule
1214
],
1315
providers: [],
1416
bootstrap: [AppComponent]

src/main/client/src/favicon.ico

-5.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)