我有一个简单的问题:在一个简单的 Angular 组件中,我们是否可以动态更改通过 http 调用检索的模板,例如:
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
/**
* Les liens link permettent de passer d'une page à l'autre.
*/
@Component({
selector: 'mycomponent',
template: '<strong>Loading…</strong>'
})
export class MyComponent implements OnInit {
//#region PROPRIÉTÉS
private moHttp : HttpClient
//#endregion
//#region CONSTRUCTEUR
constructor(poHttp: HttpClient){
this.moHttp = poHttp;
}
public ngOnInit(): void {
this.moHttp.get('https://myapiUrl').subscribe(poData:any => {
// here poData is HTML string, and I want to set it instead of the …Run Code Online (Sandbox Code Playgroud)