M
M
msdosx862018-08-14 07:10:22
JavaScript
msdosx86, 2018-08-14 07:10:22

Is it possible to use other components inside a component in Angular?

Like this

<app-component1>
   <app-component2></app-component2>
 </app-component1>

I did not find it in the documentation, maybe I was looking badly, I will be happy with the link. I tried to do this, but it doesn't output anything. I assume that everything inside `ng-template` is wrapped and therefore not visible?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
msdosx86, 2018-08-14
@msdosx86

In general, yes. It is necessary to indicate inside the first component where the second component will fall

V
Vladimir, 2018-08-14
@Casufi

https://angular.io/tutorial
See example https://stackblitz.com/angular/arpdjrkqmxj
You set a selector to a component

@Component({
  selector: 'app-hero-detail',
  templateUrl: './hero-detail.component.html',
  styleUrls: ['./hero-detail.component.css']
})

Add to parent component
<app-hero-detail [hero]="selectedHero"></app-hero-detail>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question