我有这样的要求:
import {Component, OnInit} from '@angular/core';
import { Http, Response } from '@angular/http';
import {Observable} from 'rxjs';
import 'rxjs/add/operator/map';
import {isNode} from 'angular2-universal';
@Component({
selector: 'app-todo',
templateUrl: './todo.component.html',
styleUrls: ['./todo.component.css']
})
export class TodoComponent implements OnInit {
constructor(private http: Http) {}
private todo: any;
ngOnInit() {
if(isNode) {
this.http
.get('http://api.pushsc.com/api/v1/code/show/589ceab40a58d602a0b99d10')
.map((response: Response) => response.json())
.subscribe(data => {
console.log(data);
this.todo = data;
})
error => {
console.log(error);
};
}
}
}
在控制台中,我得到来自 API 的响应,这意味着来自服务器的 http 工作......但是即使我isNode
从 http 中删除内容而不是按应有的方式呈现,poroblem 也在客户端上......可能是什么问题?