angular - 服务器端不呈现 http 请求 [Angular Universal]

标签 angular angular-universal universal-cli

当我“查看源代码”时,我无法从 api 的 http 请求中获取任何员工,看起来员工不是来自服务器。

所以我可以在源代码中看到静态 html,但在 http 请求中什么也看不到....

有人知道什么是问题吗?

我正在使用 universal-cli

编辑:

这是来 self 的 showcode.service.ts 的 http 调用示例:

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

}

这是一个活生生的例子:http://pushsc.com/show/code/58bc83760a58d602a0b99d14检查 html 的源代码...它呈现出 evertying 期望来自 http 的东西...

最佳答案

尝试将您的 Angular 更新为 4.0.0。

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

关于angular - 服务器端不呈现 http 请求 [Angular Universal],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42742169/

相关文章:

angular - Angular CLI 的 Webpack 构建失败 - 意外的 token

Angular Universal 预生成页面 : The selector "app-root" did not match any elements

angular - 在 Angular2 中获取 'nativeElement.querySelector is not a function' 异常

spring - 使用单个请求发送 JSON 和图像。 Angular + Spring 引导

navigation - Angular 2 Router 从 alpha 34 版本开始就坏了

angular - 在组件之间共享一个 observable/在 Angular2 中多播一个 observable

forms - 如何以编程方式将焦点设置为在 Angular2 中动态创建的 FormControl