0

Based on below sample

// Parent
@Component({
  selector: 'parent',
  template: `...
               <app-form-wrapper [someInput]="someInput" [otherInput]="otherInput">
                <input>
                other html ...
               /app-form-wrapper>
             ...
            `
})
export class ParentComponent {}

// Child
@Component({
  selector: 'app-form-wrapper',
  template: '<div></div>'
})
export class FormWrapperComponent {}

Is it possible for FormWrapper component to get those code/HTML wrapped by itself at parent template?

In this case, I wish my FormWrapper component able to get '< input> other HTML ...'

Please don't suggest pass in as an input.

1 Answer 1

2

Yes, you can using ng-content and transclusion:

// Child
@Component({
  selector: 'app-form-wrapper',
  template: '<div><ng-content></ng-content></div>'
})
export class FormWrapperComponent {}
Sign up to request clarification or add additional context in comments.

1 Comment

is there a way to get the content in FormWrapperComponent constructor but not from template?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.