NDDTConti
NDDTConti

Reputation: 177

Angular Component with tr as container

I have a table and I am creating angular components as rows for that table:

  <tbody>
    <ng-template appAddTableRows></ng-template>
  </tbody>

This is the Code creating the Component

let componentFactory = this.componentFactoryResolver.resolveComponentFactory(RowComponent);
let componentRef = this.flightRows.viewContainerRef.createComponent(componentFactory);

I edited the component selector to this: [app-row] So now it works but I have a useless div-Container around every row. For example:

<div app-row="" _nghost-c19=""><tr _ngcontent-c19=""> row works</tr></div>

I would prefer if that container would be a tr. And I could get rid of the div. How to achieve this?

Upvotes: 1

Views: 569

Answers (1)

user184994
user184994

Reputation: 18271

You can change the selector. Instead of [app-row] (or whatever it currently is), change it to tr[app-row], and remove the tr tag from the template

Upvotes: 2

Related Questions