Angular 2,使数据无法使用

时间:2016-01-25 03:38:21

标签: angular

我目前正在尝试使用Angular 2,并且无法查看从我创建的服务返回的数据。在开发人员工具中,我看到for (int i = 0; i < x; i++) { delete[] pixelArray[i]; } delete[] pixelArray; api调用触发,但我从未在视图中看到任何数据。有任何想法吗?我错过了一些明显的东西吗?

SubjectService.ts

getSubjects()

DashboardComponent.ts

import {Injectable} from "angular2/core";
import {Http, Response, HTTP_PROVIDERS} from "angular2/http";

@Injectable()
export class SubjectService{
    constructor(public http: Http){

    }

   getSubject(){
       return this.http.request('/subjects.json')
         .map(response => response.json())
            .subscribe(
                res => this.subjects = res,
                err => this.logError(err)
            );
    }
}

1 个答案:

答案 0 :(得分:3)

移动

Dim rand As Random = New Random(DateTime.Now.Millisecond * DateTime.Now.Second * DateTime.Now.Minute * DateTime.Now.Hour)

从服务到组件应该正常工作

.subscribe(
            res => this.subjects = res,
            err => this.logError(err)
        )