|
1 |
| -import {Component, ElementRef, Inject, Input, OnDestroy, OnInit, Renderer2} from '@angular/core'; |
| 1 | +import {Component, HostBinding, Inject, Input, OnDestroy, OnInit, Renderer2} from '@angular/core'; |
2 | 2 | import {DOCUMENT} from '@angular/common';
|
3 | 3 |
|
4 |
| -import {Replace} from '../shared'; |
5 |
| - |
6 | 4 | @Component({
|
7 |
| - selector: 'app-footer', |
8 |
| - template: ` |
9 |
| - <ng-container class="app-footer"></ng-container> |
10 |
| - <footer class="app-footer"> |
11 |
| - <ng-content></ng-content> |
12 |
| - </footer> |
13 |
| - ` |
| 5 | + selector: 'app-footer, cui-footer', |
| 6 | + template: `<ng-content></ng-content>` |
14 | 7 | })
|
15 | 8 | export class AppFooterComponent implements OnInit, OnDestroy {
|
16 | 9 | @Input() fixed: boolean;
|
17 | 10 |
|
| 11 | + @HostBinding('class.app-footer') true; |
| 12 | + |
| 13 | + private readonly fixedClass = 'footer-fixed'; |
| 14 | + |
18 | 15 | constructor(
|
19 | 16 | @Inject(DOCUMENT) private document: any,
|
20 | 17 | private renderer: Renderer2,
|
21 |
| - private el: ElementRef |
22 | 18 | ) {}
|
23 | 19 |
|
24 | 20 | ngOnInit(): void {
|
25 |
| - Replace(this.el); |
26 | 21 | this.isFixed(this.fixed);
|
27 | 22 | }
|
28 | 23 |
|
29 | 24 | ngOnDestroy(): void {
|
30 |
| - this.renderer.removeClass(this.document.body, 'footer-fixed'); |
| 25 | + this.renderer.removeClass(this.document.body, this.fixedClass); |
31 | 26 | }
|
32 | 27 |
|
33 | 28 | isFixed(fixed: boolean = this.fixed): void {
|
34 | 29 | if (fixed) {
|
35 |
| - this.renderer.addClass(this.document.body, 'footer-fixed'); |
| 30 | + this.renderer.addClass(this.document.body, this.fixedClass); |
36 | 31 | }
|
37 | 32 | }
|
38 | 33 | }
|
0 commit comments