• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atinc / ngx-tethys / d9ae709b-3c27-4b69-b125-b8b80b54f90b

pending completion
d9ae709b-3c27-4b69-b125-b8b80b54f90b

Pull #2757

circleci

mengshuicmq
fix: fix code review
Pull Request #2757: feat(color-picker): color-picker support disabled (#INFR-8645)

98 of 6315 branches covered (1.55%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2392 of 13661 relevant lines covered (17.51%)

83.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

11.76
/src/shared/directives/string-or-template-outlet.directive.ts
1
import { Directive, EmbeddedViewRef, Input, OnChanges, Renderer2, SimpleChanges, TemplateRef, ViewContainerRef } from '@angular/core';
2
import { isTemplateRef } from 'ngx-tethys/util';
3

4
/**
5
 * @name thyStringOrTemplateOutlet
6
 */
7
@Directive({
1✔
8
    selector: '[thyStringOrTemplateOutlet]',
9
    exportAs: 'thyStringOrTemplateOutlet',
×
10
    standalone: true
×
11
})
12
export class ThyStringOrTemplateOutletDirective implements OnChanges {
13
    private viewRef: EmbeddedViewRef<any>;
×
14

×
15
    private textNode: Text;
16

×
17
    @Input() thyStringOrTemplateOutletContext: any;
×
18

19
    @Input() thyStringOrTemplateOutlet: any | TemplateRef<any>;
20

21
    constructor(private viewContainerRef: ViewContainerRef, private renderer: Renderer2) {}
×
22

×
23
    ngOnChanges(changes: SimpleChanges): void {
×
24
        if (changes['thyStringOrTemplateOutlet']) {
×
25
            this.updateView();
26
        } else if (this.viewRef && changes['thyStringOrTemplateOutletContext'] && this.thyStringOrTemplateOutletContext) {
27
            this.viewRef.context = this.thyStringOrTemplateOutletContext;
×
28
        }
×
29
    }
×
30

31
    private updateView() {
32
        this.clear();
33

×
34
        if (this.thyStringOrTemplateOutlet) {
35
            if (isTemplateRef(this.thyStringOrTemplateOutlet)) {
36
                this.viewRef = this.viewContainerRef.createEmbeddedView(
37
                    this.thyStringOrTemplateOutlet,
×
38
                    this.thyStringOrTemplateOutletContext
×
39
                );
×
40
            } else {
41
                this.textNode = this.renderer.createText(this.thyStringOrTemplateOutlet + '');
42
                const element = this.viewContainerRef.element.nativeElement as HTMLElement;
1✔
43
                this.renderer.insertBefore(element.parentNode, this.textNode, element);
44
            }
45
        } else {
46
            this.viewRef = null;
1✔
47
        }
48
    }
49

50
    private clear() {
51
        this.viewContainerRef.clear();
1✔
52
        if (this.textNode) {
53
            this.renderer.removeChild(this.textNode.parentNode, this.textNode);
54
        }
55
    }
56
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc