Skip to content

Commit 119cbb7

Browse files
committed
fix(badge): adding type for value #8077
1 parent 07749c4 commit 119cbb7

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="igx-badge__circle" [ngClass]="setClasses()" [attr.aria-roledescription]="roleDescription">
1+
<div class="igx-badge__circle" [ngClass]="setClasses()">
22
<span *ngIf="!icon" class="igx-badge__circle-value">{{value}}</span>
33
<igx-icon *ngIf="icon" fontSet="material">{{icon}}</igx-icon>
44
</div>

projects/igniteui-angular/src/lib/badge/badge.component.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class IgxBadgeComponent {
8787
* ```
8888
*/
8989
@Input()
90-
public value = '';
90+
public value: string | number = '';
9191

9292
/**
9393
* Sets/gets an icon for the badge from the material icons set.
@@ -153,19 +153,15 @@ export class IgxBadgeComponent {
153153
* @hidden
154154
* @internal
155155
*/
156+
@HostBinding('attr.aria-roledescription')
156157
get roleDescription() {
157-
let message: string;
158-
159158
// tslint:disable-next-line:prefer-conditional-expression
160159
if (this.icon) {
161-
message = this.type + ' type badge with icon type ' + this.icon;
162-
} else if (this.value) {
163-
message = this.type + ' badge type with value ' + this.value;
164-
} else {
165-
message = this.type + ' badge type without value';
160+
return this.type + ' type badge with icon type ' + this.icon;
161+
} else if (this.value || this.value === 0) {
162+
return this.type + ' badge type with value ' + this.value;
166163
}
167-
168-
return message;
164+
return this.type + ' badge type without value';
169165
}
170166

171167
/**

0 commit comments

Comments
 (0)