Created
June 28, 2022 10:28
-
-
Save wpflames/fa30709b21aff51dc4b33520df4773d9 to your computer and use it in GitHub Desktop.
Display data from server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { HttpClient } from '@angular/common/http'; | |
| import { Component } from '@angular/core'; | |
| @Component({ | |
| selector: 'posts', | |
| templateUrl: './posts.component.html', | |
| styleUrls: ['./posts.component.scss'] | |
| }) | |
| export class PostsComponent { | |
| posts: any; | |
| constructor(http: HttpClient) { | |
| http.get('https://jsonplaceholder.typicode.com/posts').subscribe(res => { | |
| this.posts = res; | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment