我有一个全新的 angular 通用项目,它似乎伪装了所有的 HTML(这很好)。但是,我正在尝试对我的 .NET 服务器进行 API 调用,该服务器是使用 weatherforecast API 构建的标准 API。
API 调用并且效果很好,但只有在我的 Web 应用程序从预渲染切换到 csr 后才会发生。参见示例 1。
示例 1
如果我在页面上禁用 javascript,这就是我得到的
这是 HTML 代码
<div style="padding: 5rem">
<h1>TEST</h1>
<h2>{{ this.SampleMessage }}</h2>
<div *ngFor="let product of weather$ | async">
<p>{{ this.product.summary }}</p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
app.component.ts
import { AppService } from './app.service';
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
title …
Run Code Online (Sandbox Code Playgroud) .net prerender server-side-rendering angular-universal angular