我正在使用 Angular 在控制台中获取数据,但我无法在 html 中呈现它

I am getting Data in Console Using Angular but I can't render it in html

这是我的主页-datail.component.ts

export class PageDetailComponent implements OnInit {

  private apiUrl="http://localhost:3000/pages"

  pages={};
  // data={};

  constructor(private route:ActivatedRoute,private page:PageService,private router: Router,private http:Http) { }

  ngOnInit() {
    this.getpage(this.route.snapshot.params['title']);
    // this.getPages();
    // this.getData();

  }
  getpage(title) {
    this.page.getPage(title)
      .subscribe(pages => {
        console.log(pages);
        this.pages = pages;
      }, err => {
        console.log(err);
      });
  }

这是我在控制台中得到的响应。我收到这个 Object Object Error 并且无法在 html.

中呈现它
<a *ngFor="let p of pages" class="list-group-item list-group-item-action">
  {{p.title}}
</a>

This is the response I am getting in the console

原因是我得到这个是我在对象而不是数组中返回我的数据我这样做就像

{{pages.title}} 

你可以像这样制作对象

pages:any={};   //For Objects
page:any=[];    //For Arrays

试试这个,

export class PageDetailComponent implements OnInit {

  private apiUrl="http://localhost:3000/pages"

  pages=[];
  // data={};

  constructor(private route:ActivatedRoute,private page:PageService,private router: Router,private http:Http) { }

  ngOnInit() {
    this.getpage(this.route.snapshot.params['title']);
    // this.getPages();
    // this.getData();

  }
  getpage(title) {
    this.page.getPage(title)
      .subscribe(page => {
        console.log(page);
        this.pages.push(page);
      }, err => {
        console.log(err);
      });
  }