15

Is it possible to add a component and keep only it's content?

Example of using a component:

<my-custom-component></my-custom-component>

This is rendered like:

<my-custom-component>
  <div> ... </div>
</my-custom-component>

Is it possible to render the content only? In this case it would be:

<div> ... </div>

I need this cause is screwing my CSS rules.

1 Answer 1

8

There is feature request that looks like you want to have

For now you can workaround it by using attribute selector:

<div myComponent> ... </div>


@Component({
  selector: '[myComponent]'
  ...
})
Sign up to request clarification or add additional context in comments.

4 Comments

I've tried this before, selector: '[copy-tags-button]' and use like <div copy-tags-button [hidden]="favoritesActionBarStatus" [tags]="favorite.tags" tags-source="Favorites" item-end></div> but the wrapper is still there.
You can have only div on which you added attribute
I tried now again with only <div copy-tags-button></div>, but the content still inside the wrapper.
Content will be always inside wrapper but you can choose which wrapper it will be See similar approach. stackoverflow.com/questions/47758430/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.