0
在這裏,我訪問HTTP服務創建一個簡單的服務,請helpme我如何能在* ngFor如何消費服務數據* 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
}
她如何將數據保存在一個變量中並用於
https://angular.io/docs/ts/latest/guide/dependency-injection.html –
你是什麼意思通過創建一個簡單的構造函數來訪問http服務? – Sajeetharan
yes在這裏訪問這個http就像this.http.get('api/Employee')。subscribe(response => { this.student = response.json(); }) –