0

im new into creating angular web component. im struggling to find a way to embed html elements inside the angular component

<stepper>
    <step title="1"></step>
    <step title="2"></step>
    <step title="3"></step>

    <h1>THIS IS JUST A TEST</h1>
</stepper>

everytime i ran the component on the storybook (i mean inside the .stories.ts)

the h1 tag i have added does not display at all.. is there any requirements or necessary thing to do in order to embed html tag on the component that im currently creating?

but when i place the h1 tag outside the component it works

    <stepper>
        <step title="1"></step>
        <step title="2"></step>
        <step title="3"></step>
    </stepper>
<h1>THIS IS JUST A TEST</h1>

thanks!

1
  • What is the angular version you use? Commented Jan 31, 2022 at 6:42

1 Answer 1

1

You need to use content projection (https://angular.io/guide/content-projection) within your <stepper> component template.

template:'
  // existing template
  <ng-content></ng-content>
  // existing template
'

Whatever you put inside stepper will be inserted in place of ng-content.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.