Dynamically load HTML template in angular2

后端 未结 5 1506
余生分开走
余生分开走 2020-11-28 06:54

I have created a project using angular-cli which contains AppComponent as follows:

import { Component } from \'@angular/core\';         


        
5条回答
  •  失恋的感觉
    2020-11-28 07:17

    worked with angular 6

    import { Component, Input } from '@angular/core';
    import { HttpClient } from '@angular/common/http';
    
    @Component({
      selector: 'app-root',
      template: `
                
    `, styleUrls: ['./app.component.css'] }) export class AppComponent { private myTemplate: any = ''; constructor(http: HttpClient) { http.get('/service-path', {responseType: 'text'}).subscribe(data => this.myTemplate = data); } }

提交回复
热议问题