• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In
No new info detected.

IgniteUI / igniteui-angular / 16053471080

03 Jul 2025 02:41PM UTC coverage: 4.981% (-86.4%) from 91.409%
16053471080

Pull #16021

github

web-flow
Merge 7c49966eb into 7e40671a1
Pull Request #16021: fix(radio-group): dynamically added radio buttons do not initialize

178 of 15753 branches covered (1.13%)

13 of 14 new or added lines in 2 files covered. (92.86%)

25644 existing lines in 324 files now uncovered.

1478 of 29670 relevant lines covered (4.98%)

0.51 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 { IBaseEventArgs } from '../../core/utils';
13
import { IgxBaseButtonType, IgxButtonBaseDirective } from './button-base';
14

15
const IgxButtonType = {
3✔
16
    ...IgxBaseButtonType,
17
    FAB: 'fab'
18
} as const;
19

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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