File tree Expand file tree Collapse file tree 4 files changed +12
-1
lines changed
Expand file tree Collapse file tree 4 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 11import { 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} )
89export class AppComponent {
910 title = 'app' ;
11+ data = { } ;
12+ constructor ( private http : HttpClient ) {
13+ http . get ( 'resource' ) . subscribe ( data => { this . data = data ; } ) ;
14+ }
1015}
Original file line number Diff line number Diff line change @@ -2,13 +2,15 @@ import { BrowserModule } from '@angular/platform-browser';
22import { NgModule } from '@angular/core' ;
33
44import { 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 ]
You can’t perform that action at this time.
0 commit comments