Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #15013 #15371

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/app/components/card/card.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { CommonModule } from '@angular/common';
import { AfterContentInit, ChangeDetectionStrategy, Component, ContentChild, ContentChildren, ElementRef, Input, NgModule, QueryList, TemplateRef, ViewEncapsulation } from '@angular/core';
import { AfterContentInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, ContentChildren, ElementRef, Input, NgModule, QueryList, SimpleChange, TemplateRef, ViewEncapsulation, signal } from '@angular/core';
import { BlockableUI, Footer, Header, PrimeTemplate, SharedModule } from 'primeng/api';
import { ObjectUtils } from '../utils/objectutils';
/**
* Card is a flexible container component.
* @group Components
*/
@Component({
selector: 'p-card',
template: `
<div [ngClass]="'p-card p-component'" [ngStyle]="style" [class]="styleClass" [attr.data-pc-name]="'card'">
<div [ngClass]="'p-card p-component'" [ngStyle]="_style()" [class]="styleClass" [attr.data-pc-name]="'card'">
<div class="p-card-header" *ngIf="headerFacet || headerTemplate">
<ng-content select="p-header"></ng-content>
<ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
Expand Down Expand Up @@ -55,7 +56,11 @@ export class Card implements AfterContentInit, BlockableUI {
* Inline style of the element.
* @group Props
*/
@Input() style: { [klass: string]: any } | null | undefined;
@Input() set style(value: { [klass: string]: any } | null | undefined) {
if (!ObjectUtils.equals(this._style(), value)) {
this._style.set(value);
}
}
/**
* Class of the element.
* @group Props
Expand All @@ -78,6 +83,8 @@ export class Card implements AfterContentInit, BlockableUI {

footerTemplate: TemplateRef<any> | undefined;

_style = signal<{ [klass: string]: any } | null | undefined>(null);

constructor(private el: ElementRef) {}

ngAfterContentInit() {
Expand Down
Loading