在 Angular 10 中找不到名称 'Http'
Cannot find name 'Http' in Angular 10
我想在我的 Angular 组件中呈现外部输入模板。但是找不到 'http'。我还在项目中安装了@types/node,但没有解决依赖关系。
我正在尝试通过此代码进行设置:
<div style="height: 300px;">
<div [innerHTML]="stepTemplate"></div>
</div>
setView() {
const temp = this.inputModel.templateUrl;
this.stepTemplate = this.http.get(temp).map((html: any) => this.stepTemplate = html);
}
import * as Http from 'http';
export class JourneyLineComponent implements OnInit, AfterViewInit {
.....
http: Http;
}
我相信这就是您要导入的内容
从“@angular/common/http”导入 {HttpClient};
Angular 从几个版本前的 Http 切换到 HttpClient
此外,您想将其注入构造函数,所以
构造函数(私有 http:HttpClient){}
我想在我的 Angular 组件中呈现外部输入模板。但是找不到 'http'。我还在项目中安装了@types/node,但没有解决依赖关系。
我正在尝试通过此代码进行设置:
<div style="height: 300px;">
<div [innerHTML]="stepTemplate"></div>
</div>
setView() {
const temp = this.inputModel.templateUrl;
this.stepTemplate = this.http.get(temp).map((html: any) => this.stepTemplate = html);
}
import * as Http from 'http';
export class JourneyLineComponent implements OnInit, AfterViewInit {
.....
http: Http;
}
我相信这就是您要导入的内容
从“@angular/common/http”导入 {HttpClient};
Angular 从几个版本前的 Http 切换到 HttpClient
此外,您想将其注入构造函数,所以
构造函数(私有 http:HttpClient){}