如何在 *ngFor 中使用服务数据

How consume serve data in *ngFor

这里我创建了一个访问http服务的简单服务,请帮助我如何在*ngFor

中绑定这个服务信息
    import { Component } from '@angular/core';
     import {Http } from '@angular/http';
import { Injectable } from '@angular/core';
    @Injectable()
    export class EmployeeService {
        constructor(private http: Http) { }
    GetStudentData() {

        this.http.get('api/Employee').subscribe(response => {

            this.student = response.json();
                })
    }
    }

Student.component.ts

 GetStudentData() {
        var studentser = this.EmpServ.GetStudentData();
                     //Here How can i Bind

    }

她如何将数据保存在一个变量中并在

中使用

您需要return来自服务的数据并绑定到组件内部,

GetStudentData() {
       this.http.get('api/Employee').subscribe(response => {
       this.student = response.json();
       })
  return this.student;
}