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

IgniteUI / igniteui-angular / 16193550997

10 Jul 2025 11:12AM UTC coverage: 4.657% (-87.0%) from 91.64%
16193550997

Pull #16028

github

web-flow
Merge f7a9963b8 into 87246e3ce
Pull Request #16028: fix(radio-group): dynamically added radio buttons do not initialize

178 of 15764 branches covered (1.13%)

18 of 19 new or added lines in 2 files covered. (94.74%)

25721 existing lines in 324 files now uncovered.

1377 of 29570 relevant lines covered (4.66%)

0.53 hits per line

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

8.0
/projects/igniteui-angular/src/lib/directives/button/button.directive.ts
1
import {
2
    Directive,
3
    ElementRef,
4
    EventEmitter,
5
    HostBinding,
6
    HostListener,
7
    Input,
8
    Output,
9
    Renderer2,
10
    booleanAttribute,
11
} from '@angular/core';
12
import { mkenum } from '../../core/utils';
13
import { IBaseEventArgs } from '../../core/utils';
14
import { IgxBaseButtonType, IgxButtonBaseDirective } from './button-base';
15

16
const IgxButtonType = /*@__PURE__*/mkenum({
3✔
17
    ...IgxBaseButtonType,
18
    FAB: 'fab'
19
});
20

21
/**
22
 * Determines the Button type.
23
 */
24
export type IgxButtonType = typeof IgxButtonType[keyof typeof IgxButtonType];
25

26
/**
27
 * The Button directive provides the Ignite UI Button functionality to every component that's intended to be used as a button.
28
 *
29
 * @igxModule IgxButtonModule
30
 *
31
 * @igxParent Data Entry & Display
32
 *
33
 * @igxTheme igx-button-theme
34
 *
35
 * @igxKeywords button, span, div, click
36
 *
37
 * @remarks
38
 * The Ignite UI Button directive is intended to be used by any button, span or div and turn it into a fully functional button.
39
 *
40
 * @example
41
 * ```html
42
 * <button type="button" igxButton="outlined">A Button</button>
43
 * ```
44
 */
45
@Directive({
46
    selector: '[igxButton]',
47
    standalone: true
48
})
49
export class IgxButtonDirective extends IgxButtonBaseDirective {
3✔
50
    private static ngAcceptInputType_type: IgxButtonType | '';
51

52
    /**
53
     * Called when the button is selected.
54
     */
55
    @Output()
UNCOV
56
    public buttonSelected = new EventEmitter<IButtonEventArgs>();
×
57

58
    /**
59
     * @hidden
60
     * @internal
61
     */
62
    @HostBinding('class.igx-button')
UNCOV
63
    public _cssClass = 'igx-button';
×
64

65
    /**
66
     * @hidden
67
     * @internal
68
     */
69
    private _type: IgxButtonType;
70

71
    /**
72
     * @hidden
73
     * @internal
74
     */
75
    private _color: string;
76

77
    /**
78
     * @hidden
79
     * @internal
80
     */
81
    private _label: string;
82

83
    /**
84
     * @hidden
85
     * @internal
86
     */
87
    private _backgroundColor: string;
88

89
    /**
90
     * @hidden
91
     * @internal
92
     */
UNCOV
93
    private _selected = false;
×
94

95
    @HostListener('click')
96
    protected emitSelected() {
UNCOV
97
        this.buttonSelected.emit({
×
98
            button: this
99
        });
100
    }
101

102
    /**
103
     * Gets or sets whether the button is selected.
104
     * Mainly used in the IgxButtonGroup component and it will have no effect if set separately.
105
     *
106
     * @example
107
     * ```html
108
     * <button type="button" igxButton="flat" [selected]="button.selected"></button>
109
     * ```
110
     */
111
    @Input({ transform: booleanAttribute })
112
    public set selected(value: boolean) {
UNCOV
113
        if (this._selected !== value) {
×
UNCOV
114
            this._selected = value;
×
UNCOV
115
            this._renderer.setAttribute(this.nativeElement, 'data-selected', value.toString());
×
116
        }
117
    }
118

119
    public get selected(): boolean {
UNCOV
120
        return this._selected;
×
121
    }
122

123
    constructor(
UNCOV
124
        public override element: ElementRef,
×
UNCOV
125
        private _renderer: Renderer2,
×
126
    ) {
UNCOV
127
        super(element);
×
128
    }
129

130
    /**
131
     * Sets the type of the button.
132
     *
133
     * @example
134
     * ```html
135
     * <button type="button" igxButton="outlined"></button>
136
     * ```
137
     */
138
    @Input('igxButton')
139
    public set type(type: IgxButtonType) {
UNCOV
140
        const t = type ? type : IgxButtonType.Flat;
×
UNCOV
141
        if (this._type !== t) {
×
UNCOV
142
            this._type = t;
×
143
        }
144
    }
145

146
    /**
147
     * Sets the `aria-label` attribute.
148
     *
149
     * @example
150
     *  ```html
151
     * <button type="button" igxButton="flat" igxLabel="Label"></button>
152
     * ```
153
     */
154
    @Input('igxLabel')
155
    public set label(value: string) {
UNCOV
156
        this._label = value || this._label;
×
UNCOV
157
        this._renderer.setAttribute(this.nativeElement, 'aria-label', this._label);
×
158
    }
159

160
    /**
161
     * @hidden
162
     * @internal
163
     */
164
    @HostBinding('class.igx-button--flat')
165
    public get flat(): boolean {
UNCOV
166
        return this._type === IgxButtonType.Flat;
×
167
    }
168

169
    /**
170
     * @hidden
171
     * @internal
172
     */
173
    @HostBinding('class.igx-button--contained')
174
    public get contained(): boolean {
UNCOV
175
        return this._type === IgxButtonType.Contained;
×
176
    }
177

178
    /**
179
     * @hidden
180
     * @internal
181
     */
182
    @HostBinding('class.igx-button--outlined')
183
    public get outlined(): boolean {
UNCOV
184
        return this._type === IgxButtonType.Outlined;
×
185
    }
186

187
    /**
188
     * @hidden
189
     * @internal
190
     */
191
    @HostBinding('class.igx-button--fab')
192
    public get fab(): boolean {
UNCOV
193
        return this._type === IgxButtonType.FAB;
×
194
    }
195

196
    /**
197
     * @hidden
198
     * @internal
199
     */
200
    public select() {
UNCOV
201
        this.selected = true;
×
202
    }
203

204
    /**
205
     * @hidden
206
     * @internal
207
     */
208
    public deselect() {
UNCOV
209
        this.selected = false;
×
UNCOV
210
        this.focused = false;
×
211
    }
212
}
213

214
export interface IButtonEventArgs extends IBaseEventArgs {
215
    button: IgxButtonDirective;
216
}
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

© 2026 Coveralls, Inc