diff --git a/projects/ngx-cream-lib/src/lib/chip/chip.component.html b/projects/ngx-cream-lib/src/lib/chip/chip.component.html index facbbac..ad43e62 100644 --- a/projects/ngx-cream-lib/src/lib/chip/chip.component.html +++ b/projects/ngx-cream-lib/src/lib/chip/chip.component.html @@ -1,11 +1,15 @@ - - {{ label }} - - - {{ label }} - - + + @if(linkUrl !== ''){ + + {{ label }} + + } @else { + + {{ label }} + + } + - + \ No newline at end of file diff --git a/projects/ngx-cream-lib/src/lib/chip/chip.component.ts b/projects/ngx-cream-lib/src/lib/chip/chip.component.ts index 7084ba2..2839bac 100644 --- a/projects/ngx-cream-lib/src/lib/chip/chip.component.ts +++ b/projects/ngx-cream-lib/src/lib/chip/chip.component.ts @@ -1,33 +1,22 @@ -import { Component, OnInit, Input, ElementRef, Renderer2 } from '@angular/core'; +import { Component, Input, ElementRef, Renderer2, inject } from '@angular/core'; @Component({ selector: 'c3m-chip', templateUrl: './chip.component.html', styleUrls: ['./chip.component.css'], }) -export class ChipComponent implements OnInit { - constructor(private elementRef: ElementRef, private renderer: Renderer2) { - this.chipIdNum = this.randomID(); - } +export class ChipComponent { + + elementRef = inject(ElementRef); + renderer = inject(Renderer2) @Input() label: string = ''; @Input() deletable: boolean = true; @Input() disabled: boolean = false; @Input() linkUrl: string = ''; - chipIdNum!: number; - chipId!: string; - - ngOnInit() { - this.chipId = 'chip' + this.chipIdNum; - } - deleteChip(): void { this.renderer.removeChild(this.elementRef.nativeElement.parentNode, this.elementRef.nativeElement); } - randomID() { - const idRandom = Math.round(Math.random() * (20000 - 1) + 1); - return idRandom; - } } diff --git a/projects/ngx-cream-lib/src/lib/collapsible/collapsible.component.ts b/projects/ngx-cream-lib/src/lib/collapsible/collapsible.component.ts index bdbf563..fc88f84 100644 --- a/projects/ngx-cream-lib/src/lib/collapsible/collapsible.component.ts +++ b/projects/ngx-cream-lib/src/lib/collapsible/collapsible.component.ts @@ -1,22 +1,15 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, Input } from '@angular/core'; @Component({ selector: 'c3m-collapsible', templateUrl: './collapsible.component.html', styleUrls: ['./collapsible.component.css'], }) -export class CollapsibleComponent implements OnInit { +export class CollapsibleComponent { @Input() summary: string = ''; @Input() isOpen: boolean = false; @Input() total: string = ''; - - randomIdValue!: number; - panelId: string = ''; - - ngOnInit(): void { - this.randomIdValue = this.randomID(); - this.panelId = 'colpanel-' + this.randomIdValue; - } + panelId = 'colpanel-' + this.randomID() randomID() { const idRandom = Math.round(Math.random() * (20000 - 1) + 1); diff --git a/projects/ngx-cream-lib/src/lib/progress-spinner/progress-spinner.component.ts b/projects/ngx-cream-lib/src/lib/progress-spinner/progress-spinner.component.ts index 7bb81c9..c7012a0 100644 --- a/projects/ngx-cream-lib/src/lib/progress-spinner/progress-spinner.component.ts +++ b/projects/ngx-cream-lib/src/lib/progress-spinner/progress-spinner.component.ts @@ -7,7 +7,7 @@ import { Component, Input } from '@angular/core'; }) export class ProgressSpinnerComponent { @Input() progressText!: string; - + isOpen: boolean = false; theId = this.randomID(); spinnerTextId = 'progress' + this.theId;