tabBody.component.ts 1.1 KB

1234567891011121314151617181920212223242526272829
  1. import { Component, Input, ViewChild, HostBinding, ViewContainerRef } from '@angular/core'
  2. import { BaseTabComponent } from '../components/baseTab.component'
  3. @Component({
  4. selector: 'tab-body',
  5. template: `
  6. <perfect-scrollbar [config]="{ suppressScrollX: true }" *ngIf="scrollable">
  7. <ng-template #scrollablePlaceholder></ng-template>
  8. </perfect-scrollbar>
  9. <ng-template #nonScrollablePlaceholder *ngIf="!scrollable"></ng-template>
  10. `,
  11. styles: [
  12. require('./tabBody.component.scss'),
  13. require('./tabBody.deep.component.css'),
  14. ],
  15. })
  16. export class TabBodyComponent {
  17. @Input() @HostBinding('class.active') active: boolean
  18. @Input() tab: BaseTabComponent
  19. @Input() scrollable: boolean
  20. @ViewChild('scrollablePlaceholder', {read: ViewContainerRef}) scrollablePlaceholder: ViewContainerRef
  21. @ViewChild('nonScrollablePlaceholder', {read: ViewContainerRef}) nonScrollablePlaceholder: ViewContainerRef
  22. ngAfterViewInit () {
  23. setImmediate(() => {
  24. (this.scrollable ? this.scrollablePlaceholder : this.nonScrollablePlaceholder).insert(this.tab.hostView)
  25. })
  26. }
  27. }