How to load the ng-template in separate file?

前端 未结 3 2211
傲寒
傲寒 2021-02-20 07:33

In below sample, I have used ng-template like below and it is working fine.

Sample link: click here

3条回答
  •  遇见更好的自我
    2021-02-20 08:09

    i got an answer for this question from github angular please check this https://github.com/angular/angular/issues/27503

    Answer:

    step1:

    i have initialized my template as a new component as like below

    template.component.ts

    import { Component, Input } from '@angular/core';
    
    @Component({
      selector: 'app-device',
      template: `
      
      {{dataSource.header}} {{dataSource.text}}
      
    `
    })
    export class DeviceComponent {
      @Input()
      dataSource: any;
    }

    Then i have used that component template in my parent component as like below

    default.html

    sample link sample click me

提交回复
热议问题