2017-03-12 37 views
9

我有问题从apis的http请求中获取任何工作人员,当我查看源代码时,它看起来像不从服务器来的工作人员。服务器端不呈现http请求[Angular Universal]

所以我可以看到源代码,但来自HTTP请求没有静态html ....

任何人都知道可能是一个问题?

我使用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()); 
    }; 

} 

这里是活生生的例子:HTML的http://pushsc.com/show/code/58bc83760a58d602a0b99d14检查源代码.. 。它提供预期的东西来自http ...

+0

发布您的模板和打字稿请 – KnowHoper

+0

您需要什么部分?我使用了'universal-cli'创建的项目,就像这样'ung new project' – Vladimir

+0

打字稿 - http调用。 – KnowHoper

回答

1

尝试更新你的角度到4.0.0。

他们修复了一些与服务器端渲染相关的bug。

+0

我也建议更新到Angular 4.但是,universal-cli不能使用(platform)服务器中的模块和服务。 –

+0

我已经花了半个月的时间来克服这个问题,然后开发了一个示例应用程序,以便其他人不会因此遭受这种情况:https://github.com/nglibs/universal-example-app –