当我查看源代码时,我从apis获取http请求的任何工作人员都有问题,看起来工作人员没有从服务器上来.
所以我可以在源代码中看到静态html,但http请求中没有任何内容.
任何人都知道什么是问题?
我在用 universal-cli
编辑:
这是我的http调用示例showcode.service.ts:
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { environment } from '../../environments/environment';
@Injectable()
export class ShowcodeService {
constructor(private http: Http) { }
getCode(id): any{
return this.http.get(environment.baseUrl + 'code/show/' + id)
.map((response: Response) => response.json());
};
}
Run Code Online (Sandbox Code Playgroud)
这是现场的例子:http://pushsc.com/show/code/58bc83760a58d602a0b99d14检查html的源代码...它渲染evertying期待来自http的东西......
我正在使用通用cli ...
我的app.node.module.ts看起来像这样:
/**
* This file and `main.browser.ts` are identical, at the moment(!)
* By splitting these, you're able to create logic, imports, etc that are "Platform" specific.
* If you want your code to be completely Universal and don't need that
* You can also just have 1 file, that is imported into both
* client.ts and server.ts
*/
import {NgModule} from '@angular/core';
import {UniversalModule} from 'angular2-universal';
import {FormsModule} from '@angular/forms';
import {AppComponent} from './index';
import {AlertModule, CollapseModule, …Run Code Online (Sandbox Code Playgroud)