Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
using router


services
- getdetails(id:number){
- this.http.get('http://localhost:1858/api/details/' + id).map((data: Response) =>{
- return data.json() as INewsModule[];
- }).toPromise().then(x=>{
- this._detailsNews = x;
- });
- }
- import { Component, OnInit } from '@angular/core';
- import { NewsService } from '../../../serv/news.service';
- import { ActivatedRoute } from '@angular/router';
- @Component({
- selector: 'app-details',
- templateUrl: './details.component.html',
- styleUrls: ['./details.component.scss'],
- providers:[NewsService]
- })
- export class DetailsComponent implements OnInit {
- constructor(private _NewsService : NewsService,
- private _activeRoute: ActivatedRoute) { }
- ngOnInit() {
- let id : number = this._activeRoute.snapshot.params['id'];
- this._NewsService.getdetails(id);
- }
- }
template
- <table class="table">
- <caption>List of userscaption>
- <thead>
- <tr>
- <th scope="col">#th>
- <th scope="col">NameNewsth>
- tr>
- thead>
- <tbody>
- <tr *ngFor="let details of _NewsService._detailsNews">
- <th scope="col"> {{details.NameNews}}th>
- {{details.TopicNews}}
- {{details.DateNews}}
- tr>
- tbody>
- table>

Manoj BhoirRank #599 · 4K reputationPosted May 5, 2019, 10:42 PM EDT
bishoe nbRank #2,471 · 568 reputationPosted May 6, 2019, 8:28 PM EDT
Mandar ShindeRank #4,584 · 336 reputationPosted May 8, 2019, 1:22 AM EDT
bishoe nbRank #2,471 · 568 reputationPosted May 8, 2019, 3:56 AM EDT
Mandar ShindeRank #4,584 · 336 reputationPosted May 8, 2019, 7:38 PM EDT
Laxmidhar SahooRank #383 · 6.6K reputationPosted May 8, 2019, 8:21 PM EDT
bishoe nbRank #2,471 · 568 reputationPosted May 9, 2019, 2:05 AM EDT
bishoe nbRank #2,471 · 568 reputationPosted May 9, 2019, 2:07 AM EDT
Laxmidhar Sahoo
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts