angular - 如何将来自http调用的简单csv数据转换为角度字符串?
问题描述
我有一个应用程序,我想在其中显示通过 http 请求创建的数据。在我要显示的视图中:2020 年格陵兰的人口为 56081 人。
此查询http://betabank.stat.gl/sq/74c8dac5-97a0-4457-ace9-057de3e1308f返回一个简单的 CSV 文件:
“”“2020”“”56081
我在浏览器中工作正常,但如何以角度导入打字稿中的内容。请参阅下面的我的 html 和打字稿。
我曾尝试在 html 中使用 embed、iframe 和其他解决方案,但无法正常工作。如何在角度应用程序中打开其他网站
请帮忙
我的html:
<div>
<h2>Test simpel http import</h2>
<p>{{outputstring}} </p>
</div>
我的打字稿:
import { Component} from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
inputstring: string;
inputnumber: string;
outputstring: string;
ngOnInit() {
this.inputstring = "The population in Greenland in 2020 are {{}} persons.";
this.inputnumber = "56081";
// I need to get inputnumber from this http-call (transformed)
// http://betabank.stat.gl/sq/74c8dac5-97a0-4457-ace9-057de3e1308f
this.outputstring = this.inputstring.replace("{{}}", this.inputnumber);
}
}
解决方案
推荐阅读
- javascript - 如何将变量从客户端传递到服务器端以设置 webchartcontol 宽度
- java - Spring Hibernate mysql:字段'id'没有默认值
- javascript - 如何将月份值从一个 Date 对象复制到另一个对象?
- php - 如何在两个或多个表中获取同一列?
- swift - 从 Swift 5 类型转换
相当于 Swift 3 - javascript - 动画推动 div 的宽度更小
- css - 在单个文件组件中导入全局常量
- debugging - 如何调试 Firefox 扩展,它似乎无声无息地崩溃
- android - 已编译的 apk 正在尝试到达 metor 服务器反应本机
- php - 以 n 为单位分离和写入数据集的功能不起作用。尝试了 array_slice 和 for-loop