O
O
Oleg2019-02-08 07:56:26
JavaScript
Oleg, 2019-02-08 07:56:26

How to make tabs in Angular like this?

Perhaps someone will prompt in what direction to think.
It is necessary to make tabs, in the headers and content of which html or other components could be passed.

<app-tabs>
   <app-tab *ngFor="let tab of tabs">
       <app-tab-title>
           <b>Title</b> of tab {{tab}}
      </app-tab-title>
      <app-tab-component>
         <b>Title</b> of tab {{tab}}
          <some-component  [tab]="tab"></some-component>
      </app-tab-component>
   </app-tab>
</app-tabs>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Eremin, 2019-02-08
@EreminD

https://blog.angular-university.io/angular-ng-temp...

M
Medin K, 2019-02-08
@medin84

In the component template, use<ng-content></ng-content>

@Component({
    selector: 'app-tab',
    template: `<ng-content></ng-content>`
})

@Component({
    selector: 'app-tab-title',
    template: `<ng-content></ng-content>`
})

V
Vasily Mazhekin, 2020-03-20
@mazhekin

Look in this direction https://www.npmjs.com/package/@codehint-ng/tabs
Here you can put anything in headers and tab content can be placed in arbitrary components in arbitrary places.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question