Created
September 20, 2017 11:10
-
-
Save elcodabra/d002a282731bbf0beb0ce1479fe3b5d2 to your computer and use it in GitHub Desktop.
View List Component for Angular
This file contains 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
<div> | |
<ul class="list-unstyled"> | |
<li class="media" *ngFor="let row of tweets; let i = index"> | |
<img class="img-thumbnail rounded-circle mr-3" [src]="row?.account?.img" /> | |
<div class="media-body"> | |
<h5 class="mt-0 mb-1">{{row?.account?.fullName || "You"}}</h5> | |
<p class="text-muted">Posted at: {{row.createdAt}}</p> | |
{{row.content}} | |
<div class="mt-2"> | |
<a href="#"> | |
<span class="fa fa-heart-o"></span> | |
</a> | |
<span class="ml-1">{{row.likes || 0}}</span> | |
</div> | |
</div> | |
</li> | |
</ul> | |
</div> |
This file contains 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 { Component, OnInit } from '@angular/core'; | |
import {BackendService} from "../../../services/backend.service"; | |
@Component({ | |
selector: 'app-home', | |
templateUrl: './tweets-list.component.html', | |
styleUrls: ['./tweets-list.component.css'] | |
}) | |
export class ListTweetsComponent implements OnInit { | |
tweets = []; | |
constructor(private backendService: BackendService) { } | |
ngOnInit() { | |
this.backendService.getTweets() | |
.then((response: any) => { | |
if (response.allTweets) { | |
this.tweets = response.allTweets; | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment