1- import { Component , HostBinding , input , InputSignal } from '@angular/core' ;
1+ import { Component , computed , input , InputSignal } from '@angular/core' ;
22import { BadgePositions , Colors , Shapes , TextColors } from '../coreui.types' ;
33import { TextBgColorDirective , TextColorDirective } from '../utilities' ;
44
@@ -11,7 +11,8 @@ import { TextBgColorDirective, TextColorDirective } from '../utilities';
1111 { directive : TextBgColorDirective , inputs : [ 'cTextBgColor: textBgColor' ] }
1212 ] ,
1313 host : {
14- class : 'badge'
14+ class : 'badge' ,
15+ '[class]' : 'hostClasses()'
1516 }
1617} )
1718export class BadgeComponent {
@@ -52,8 +53,7 @@ export class BadgeComponent {
5253 */
5354 readonly textBgColor : InputSignal < Colors | undefined > = input ( ) ;
5455
55- @HostBinding ( 'class' )
56- get hostClasses ( ) : any {
56+ readonly hostClasses = computed ( ( ) => {
5757 const position = this . position ( ) ;
5858 const positionClasses = {
5959 'position-absolute' : ! ! position ,
@@ -72,6 +72,6 @@ export class BadgeComponent {
7272 [ `${ this . shape ( ) } ` ] : ! ! this . shape ( )
7373 } ,
7474 ! ! position ? positionClasses : { }
75- ) ;
76- }
75+ ) as Record < string , boolean > ;
76+ } ) ;
7777}
0 commit comments