Reputation: 1106
I was wondering if such mechanism is allowed in Angular:
<app-form-general>
<p>Hello</p>
</app-form-general>
Angular compiles it and shows app-form-general
, but I can't find a way for it to process child element. I wanted to create component with dynamic number of elements, but sadly I guess it's not something obtainable. Or is there something to process internal child data?
Upvotes: 0
Views: 418
Reputation: 885
You should do in your component 'app-form-general'.
Where ever in your component, you want to show the child component. Add this 'ng-content'
@Component({
selector: 'app-any-component', // not app-root
template: '<button (click)="add">
<ng-content></ng-content>
</button>',
styleUrls: ['./app.component.css']
})
export class AnyComponent{
}
// Other component
<app-any-component> Hello </app-any-component>
Upvotes: 1