angular - Angular2 render template -


i have 2 components, componenta uses componentb. componentb table can retrieve data, options , template defines table content. want componentb component render different tables. have no idea how render templates in angular2 v2.1.0. found stuff dynamiccomponentloader , componentresolver both obsolete. components angular2 2.1.0 provide render templates?

componenta :

@component({     'template':<my-table [template]="template" [options]="options" [data]="data"></mytable> )} export class viewa{   template:string;   ngoninit(){       this.template = `           <tr            *ngfor="let item of items">              <td>{{item.name}}</td>           </tr>       `   } } 

componentb:

@component({ selector: 'my-table', 'template':`    <table>      <thead>         <th *ngfor="let conf of config.columns">             {{conf.title}}         </th>      </thead>      <tbody #tbody>      </tbody>    </table> ` )} export class viewb{ @input('template') template:string; @input('data') data:mydata; @input('options') options:myoptions;  constructor(){     //todo: create template element, append template element tbody element } 

} }

i watched video rob wormald on topic. little long great how yourself.

https://www.youtube.com/watch?v=zqgvilzdbac


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -