-
Category
-
-
+
`,
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [MessageService, ConfirmationService]
})
-export class ProductsDoc implements OnInit {
+export class ProductsDoc {
productDialog: boolean = false;
products!: Product[];
@@ -169,7 +171,7 @@ export class ProductsDoc implements OnInit {
constructor(private productService: ProductService, private messageService: MessageService, private confirmationService: ConfirmationService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData() {
this.productService.getProducts().then((data) => {
this.products = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/radiobuttonselectiondoc.ts b/src/app/showcase/doc/table/radiobuttonselectiondoc.ts
index 9b74b40711a..dccb0b788d8 100644
--- a/src/app/showcase/doc/table/radiobuttonselectiondoc.ts
+++ b/src/app/showcase/doc/table/radiobuttonselectiondoc.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { Code } from '../../domain/code';
import { Product } from '../../domain/product';
import { ProductService } from '../../service/productservice';
@@ -8,41 +8,43 @@ import { ProductService } from '../../service/productservice';
template: `
Single selection can also be handled using radio buttons.
-
-
-
-
-
- Code
- Name
- Category
- Quantity
-
-
-
-
-
-
-
- {{ product.code }}
- {{ product.name }}
- {{ product.category }}
- {{ product.quantity }}
-
-
-
-
+
+
+
+
+
+
+ Code
+ Name
+ Category
+ Quantity
+
+
+
+
+
+
+
+ {{ product.code }}
+ {{ product.name }}
+ {{ product.category }}
+ {{ product.quantity }}
+
+
+
+
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class RadioButtonSelectionDoc implements OnInit {
+export class RadioButtonSelectionDoc {
products!: Product[];
selectedProduct!: Product;
constructor(private productService: ProductService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData() {
this.productService.getProductsMini().then((data) => {
this.products = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/reorderdoc.ts b/src/app/showcase/doc/table/reorderdoc.ts
index 79a8e07760d..9c26405f5c6 100644
--- a/src/app/showcase/doc/table/reorderdoc.ts
+++ b/src/app/showcase/doc/table/reorderdoc.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { Code } from '../../domain/code';
import { Product } from '../../domain/product';
import { ProductService } from '../../service/productservice';
@@ -17,39 +17,41 @@ interface Column {
reorder completes.
-
-
-
-
-
-
- {{ col.header }}
-
-
-
-
-
-
-
-
-
- {{ rowData[col.field] }}
-
-
-
-
-
+
+
+
+
+
+
+
+ {{ col.header }}
+
+
+
+
+
+
+
+
+
+ {{ rowData[col.field] }}
+
+
+
+
+
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class ReorderDoc implements OnInit {
+export class ReorderDoc {
products!: Product[];
cols!: Column[];
constructor(private productService: ProductService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData() {
this.productService.getProductsSmall().then((data) => {
this.products = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/responsivescrolldoc.ts b/src/app/showcase/doc/table/responsivescrolldoc.ts
index 48687abdd63..356b4efee11 100644
--- a/src/app/showcase/doc/table/responsivescrolldoc.ts
+++ b/src/app/showcase/doc/table/responsivescrolldoc.ts
@@ -14,43 +14,45 @@ interface Column {
When there is not enough space for the table to fit all the content efficiently, table displays a horizontal scrollbar. It is suggested to give a min-width to the table to avoid design issues due wrapping of cell contents.
Following table displays a horizontal scrollbar when viewport is smaller than 50rem.
-
-
-
-
- Name
- Price
- Category
- Quantity
- Status
- Reviews
-
-
-
-
- {{ product.name }}
- {{ product.price | currency : 'USD' }}
- {{ product.category }}
- {{ product.quantity }}
-
-
-
-
-
-
-
-
+
+
+
+
+
+ Name
+ Price
+ Category
+ Quantity
+ Status
+ Reviews
+
+
+
+
+ {{ product.name }}
+ {{ product.price | currency : 'USD' }}
+ {{ product.category }}
+ {{ product.quantity }}
+
+
+
+
+
+
+
+
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class ResponsiveScrollDoc implements OnInit {
+export class ResponsiveScrollDoc {
products!: Product[];
cols!: Column[];
constructor(private productService: ProductService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData(){
this.productService.getProductsMini().then((data) => {
this.products = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/responsivestackdoc.ts b/src/app/showcase/doc/table/responsivestackdoc.ts
index e4e4196bd1e..1a0d2dda612 100644
--- a/src/app/showcase/doc/table/responsivestackdoc.ts
+++ b/src/app/showcase/doc/table/responsivestackdoc.ts
@@ -16,41 +16,43 @@ interface Column {
p-column-title style class to the body cells.
-
-
-
-
- Name
- Price
- Category
- Quantity
- Status
- Reviews
-
-
-
-
- Name {{ product.name }}
- Price {{ product.price | currency : 'USD' }}
- Category {{ product.category }}
- Quantity {{ product.quantity }}
-
- Reviews
-
-
-
-
+
+
+
+
+
+ Name
+ Price
+ Category
+ Quantity
+ Status
+ Reviews
+
+
+
+
+ Name {{ product.name }}
+ Price {{ product.price | currency : 'USD' }}
+ Category {{ product.category }}
+ Quantity {{ product.quantity }}
+
+ Reviews
+
+
+
+
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class ResponsiveStackDoc implements OnInit {
+export class ResponsiveStackDoc{
products!: Product[];
cols!: Column[];
constructor(private productService: ProductService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData(){
this.productService.getProductsMini().then((data) => {
this.products = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/roweditdoc.ts b/src/app/showcase/doc/table/roweditdoc.ts
index b61a2e7faa2..82fb996497d 100644
--- a/src/app/showcase/doc/table/roweditdoc.ts
+++ b/src/app/showcase/doc/table/roweditdoc.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { MessageService, SelectItem } from 'primeng/api';
import { Code } from '../../domain/code';
import { Product } from '../../domain/product';
@@ -21,76 +21,78 @@ import { ProductService } from '../../service/productservice';
whose key is the dataKey of the record where the value is any arbitrary number greater than zero.
-
+
+
+
`,
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [MessageService]
})
-export class RowEditDoc implements OnInit {
+export class RowEditDoc {
products!: Product[];
statuses!: SelectItem[];
@@ -99,7 +101,7 @@ export class RowEditDoc implements OnInit {
constructor(private productService: ProductService, private messageService: MessageService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData() {
this.productService.getProductsMini().then((data) => {
this.products = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/rowexpanddoc.ts b/src/app/showcase/doc/table/rowexpanddoc.ts
index 474ef4c3380..2c06eedf5d8 100644
--- a/src/app/showcase/doc/table/rowexpanddoc.ts
+++ b/src/app/showcase/doc/table/rowexpanddoc.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { Code } from '../../domain/code';
import { Product } from '../../domain/product';
import { ProductService } from '../../service/productservice';
@@ -12,6 +12,7 @@ import { ProductService } from '../../service/productservice';
event for the element.
+
@@ -79,15 +80,16 @@ import { ProductService } from '../../service/productservice';
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class RowExpandDoc implements OnInit {
+export class RowExpandDoc {
products!: Product[];
constructor(private productService: ProductService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData() {
this.productService.getProductsWithOrdersSmall().then((data) => {
this.products = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/rowspangroupingdoc.ts b/src/app/showcase/doc/table/rowspangroupingdoc.ts
index d21d5216966..6a919ca0d2b 100644
--- a/src/app/showcase/doc/table/rowspangroupingdoc.ts
+++ b/src/app/showcase/doc/table/rowspangroupingdoc.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { Code } from '../../domain/code';
import { Customer } from '../../domain/customer';
import { CustomerService } from '../../service/customerservice';
@@ -8,55 +8,57 @@ import { CustomerService } from '../../service/customerservice';
template: `
When rowGroupMode is configured to be rowspan , the grouping column spans multiple rows.
-
-
-
-
- #
- Representative
- Name
- Country
- Company
- Status
- Date
-
-
-
-
- {{ rowIndex }}
-
-
- {{ customer.representative.name }}
-
-
- {{ customer.name }}
-
-
-
- {{ customer.country.name }}
-
-
- {{ customer.company }}
-
-
-
-
-
- {{ customer.date }}
-
-
-
-
-
+
+
+
+
+
+ #
+ Representative
+ Name
+ Country
+ Company
+ Status
+ Date
+
+
+
+
+ {{ rowIndex }}
+
+
+ {{ customer.representative.name }}
+
+
+ {{ customer.name }}
+
+
+
+ {{ customer.country.name }}
+
+
+ {{ customer.company }}
+
+
+
+
+
+ {{ customer.date }}
+
+
+
+
+
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class RowspanGroupingDoc implements OnInit {
+export class RowspanGroupingDoc {
customers!: Customer[];
constructor(private customerService: CustomerService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData() {
this.customerService.getCustomersMedium().then((data) => {
this.customers = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/selectioneventsdoc.ts b/src/app/showcase/doc/table/selectioneventsdoc.ts
index b24a25a9938..d96ca39eb50 100644
--- a/src/app/showcase/doc/table/selectioneventsdoc.ts
+++ b/src/app/showcase/doc/table/selectioneventsdoc.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { MessageService } from 'primeng/api';
import { Code } from '../../domain/code';
import { Product } from '../../domain/product';
@@ -9,6 +9,7 @@ import { ProductService } from '../../service/productservice';
template: `
Table provides onRowSelect and onRowUnselect events to listen selection events.
+
@@ -30,18 +31,19 @@ import { ProductService } from '../../service/productservice';
+
`,
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [MessageService]
})
-export class SelectionEventsDoc implements OnInit {
+export class SelectionEventsDoc {
products!: Product[];
selectedProduct!: Product;
constructor(private productService: ProductService, private messageService: MessageService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData(){
this.productService.getProductsMini().then((data) => {
this.products = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/singlecolumnsortdoc.ts b/src/app/showcase/doc/table/singlecolumnsortdoc.ts
index aabda069fa0..7c89579e650 100644
--- a/src/app/showcase/doc/table/singlecolumnsortdoc.ts
+++ b/src/app/showcase/doc/table/singlecolumnsortdoc.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { Code } from '../../domain/code';
import { Product } from '../../domain/product';
import { ProductService } from '../../service/productservice';
@@ -12,6 +12,7 @@ import { ProductService } from '../../service/productservice';
Default sorting is executed on a single column, in order to enable multiple field sorting, set sortMode property to "multiple" and use metakey when clicking on another column.
+
@@ -34,15 +35,16 @@ import { ProductService } from '../../service/productservice';
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class SingleColumnSortDoc implements OnInit {
+export class SingleColumnSortDoc {
products!: Product[];
constructor(private productService: ProductService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData(){
this.productService.getProductsMini().then((data) => {
this.products = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/singleselectiondoc.ts b/src/app/showcase/doc/table/singleselectiondoc.ts
index 170791b622a..ae0e9741aaf 100644
--- a/src/app/showcase/doc/table/singleselectiondoc.ts
+++ b/src/app/showcase/doc/table/singleselectiondoc.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { Code } from '../../domain/code';
import { Product } from '../../domain/product';
import { ProductService } from '../../service/productservice';
@@ -15,37 +15,39 @@ import { ProductService } from '../../service/productservice';
setting it to false.
-
-
-
-
- Code
- Name
- Category
- Quantity
-
-
-
-
- {{ product.code }}
- {{ product.name }}
- {{ product.category }}
- {{ product.quantity }}
-
-
-
-
+
+
+
+
+
+ Code
+ Name
+ Category
+ Quantity
+
+
+
+
+ {{ product.code }}
+ {{ product.name }}
+ {{ product.category }}
+ {{ product.quantity }}
+
+
+
+
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class SingleSelectionDoc implements OnInit {
+export class SingleSelectionDoc {
products!: Product[];
selectedProduct!: Product;
constructor(private productService: ProductService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData() {
this.productService.getProductsMini().then((data) => {
this.products = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/sizedoc.ts b/src/app/showcase/doc/table/sizedoc.ts
index f2cf54c2556..b828c9691fa 100644
--- a/src/app/showcase/doc/table/sizedoc.ts
+++ b/src/app/showcase/doc/table/sizedoc.ts
@@ -8,29 +8,31 @@ import { ProductService } from '../../service/productservice';
template: `
In addition to a regular table, alternatives with alternative sizes are available.
-
-
-
+
+
+
+
+
+
+ Code
+ Name
+ Category
+ Quantity
+
+
+
+
+ {{ product.code }}
+ {{ product.name }}
+ {{ product.category }}
+ {{ product.quantity }}
+
+
+
-
-
-
- Code
- Name
- Category
- Quantity
-
-
-
-
- {{ product.code }}
- {{ product.name }}
- {{ product.category }}
- {{ product.quantity }}
-
-
-
-
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
@@ -43,7 +45,7 @@ export class SizeDoc {
constructor(private productService: ProductService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData() {
this.productService.getProductsMini().then((data) => {
this.products = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/statefuldoc.ts b/src/app/showcase/doc/table/statefuldoc.ts
index 8c196c186a4..46ff3de6f62 100644
--- a/src/app/showcase/doc/table/statefuldoc.ts
+++ b/src/app/showcase/doc/table/statefuldoc.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { Code } from '../../domain/code';
import { Customer } from '../../domain/customer';
import { CustomerService } from '../../service/customerservice';
@@ -12,6 +12,7 @@ import { CustomerService } from '../../service/customerservice';
browser is closed. Other alternative is
local referring to
localStorage for an extended lifetime.
+
@@ -65,17 +66,18 @@ import { CustomerService } from '../../service/customerservice';
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class StatefulDoc implements OnInit {
+export class StatefulDoc {
customers!: Customer[];
selectedCustomers!: Customer;
constructor(private customerService: CustomerService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData() {
this.customerService.getCustomersMini().then((data) => {
this.customers = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/stripeddoc.ts b/src/app/showcase/doc/table/stripeddoc.ts
index 2bcbb8f7d2e..173dd8b3920 100644
--- a/src/app/showcase/doc/table/stripeddoc.ts
+++ b/src/app/showcase/doc/table/stripeddoc.ts
@@ -8,26 +8,28 @@ import { ProductService } from '../../service/productservice';
template: `
Adding p-datatable-striped class displays striped rows.
-
-
-
-
- Code
- Name
- Category
- Quantity
-
-
-
-
- {{ product.code }}
- {{ product.name }}
- {{ product.category }}
- {{ product.quantity }}
-
-
-
-
+
+
+
+
+
+ Code
+ Name
+ Category
+ Quantity
+
+
+
+
+ {{ product.code }}
+ {{ product.name }}
+ {{ product.category }}
+ {{ product.quantity }}
+
+
+
+
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
@@ -36,7 +38,7 @@ export class StripedDoc {
constructor(private productService: ProductService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData() {
this.productService.getProductsMini().then((data) => {
this.products = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/styledoc.ts b/src/app/showcase/doc/table/styledoc.ts
index 55cf647938f..8155d893a46 100644
--- a/src/app/showcase/doc/table/styledoc.ts
+++ b/src/app/showcase/doc/table/styledoc.ts
@@ -8,30 +8,32 @@ import { ProductService } from '../../service/productservice';
template: `
Certain rows or cells can easily be styled based on conditions.
-
-
-
-
- Code
- Name
- Category
- Quantity
-
-
-
-
- {{ product.code }}
- {{ product.name }}
- {{ product.category }}
-
- 0 && product.quantity < 10, instock: product.quantity > 10 }">
- {{ product.quantity }}
-
-
-
-
-
-
+
+
+
+
+
+ Code
+ Name
+ Category
+ Quantity
+
+
+
+
+ {{ product.code }}
+ {{ product.name }}
+ {{ product.category }}
+
+ 0 && product.quantity < 10, instock: product.quantity > 10 }">
+ {{ product.quantity }}
+
+
+
+
+
+
+
`,
changeDetection: ChangeDetectionStrategy.OnPush,
styles: [
@@ -58,12 +60,12 @@ import { ProductService } from '../../service/productservice';
`
]
})
-export class StyleDoc implements OnInit {
+export class StyleDoc {
products!: Product[];
constructor(private productService: ProductService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData() {
this.productService.getProductsMini().then((data) => {
this.products = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/subheadergroupingdoc.ts b/src/app/showcase/doc/table/subheadergroupingdoc.ts
index be2a4dea9dd..72d68b02d64 100644
--- a/src/app/showcase/doc/table/subheadergroupingdoc.ts
+++ b/src/app/showcase/doc/table/subheadergroupingdoc.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { Code } from '../../domain/code';
import { Customer } from '../../domain/customer';
import { CustomerService } from '../../service/customerservice';
@@ -11,61 +11,63 @@ import { CustomerService } from '../../service/customerservice';
footer with
groupfooter templates.
-
-
-
-
- Name
- Country
- Company
- Status
- Date
-
-
-
-
-
-
- {{ customer.representative.name }}
-
-
-
-
-
- Total Customers: {{ calculateCustomerTotal(customer.representative.name) }}
-
-
-
-
-
- {{ customer.name }}
-
-
-
- {{ customer.country.name }}
-
-
- {{ customer.company }}
-
-
-
-
-
- {{ customer.date }}
-
-
-
-
-
+
+
+
+
+
+ Name
+ Country
+ Company
+ Status
+ Date
+
+
+
+
+
+
+ {{ customer.representative.name }}
+
+
+
+
+
+ Total Customers: {{ calculateCustomerTotal(customer.representative.name) }}
+
+
+
+
+
+ {{ customer.name }}
+
+
+
+ {{ customer.country.name }}
+
+
+ {{ customer.company }}
+
+
+
+
+
+ {{ customer.date }}
+
+
+
+
+
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class SubheaderGroupingDoc implements OnInit {
+export class SubheaderGroupingDoc {
customers!: Customer[];
constructor(private customerService: CustomerService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData() {
this.customerService.getCustomersMedium().then((data) => {
this.customers = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/tabledoc.module.ts b/src/app/showcase/doc/table/tabledoc.module.ts
index 2f8439f32f0..36925424477 100644
--- a/src/app/showcase/doc/table/tabledoc.module.ts
+++ b/src/app/showcase/doc/table/tabledoc.module.ts
@@ -81,7 +81,7 @@ import { StylingDoc } from './stylingdoc';
import { SelectionEventsDoc } from './selectioneventsdoc';
import { AccessibilityDoc } from './accessibilitydoc';
import { PaginatorLocaleDoc } from './paginatorlocaledoc';
-
+import { DeferredDemoModule } from 'primeng/demo';
@NgModule({
imports: [
CommonModule,
@@ -112,7 +112,8 @@ import { PaginatorLocaleDoc } from './paginatorlocaledoc';
SkeletonModule,
SelectButtonModule,
AppCodeModule,
- AppDocModule
+ AppDocModule,
+ DeferredDemoModule
],
declarations: [
ImportDoc,
diff --git a/src/app/showcase/doc/table/templatedoc.ts b/src/app/showcase/doc/table/templatedoc.ts
index eb84559c35a..8200e98ad42 100644
--- a/src/app/showcase/doc/table/templatedoc.ts
+++ b/src/app/showcase/doc/table/templatedoc.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { Code } from '../../domain/code';
import { Product } from '../../domain/product';
import { ProductService } from '../../service/productservice';
@@ -13,52 +13,54 @@ interface Column {
template: `
Custom content at header , body and footer sections are supported via templating.
-
-
-
-
-
-
-
- Name
- Image
- Price
- Category
- Reviews
- Status
-
-
-
-
- {{ product.name }}
-
- {{ product.price | currency : 'USD' }}
- {{ product.category }}
-
-
-
-
-
-
-
- In total there are {{ products ? products.length : 0 }} products.
-
-
-
+
+
+
+
+
+
+
+
+ Name
+ Image
+ Price
+ Category
+ Reviews
+ Status
+
+
+
+
+ {{ product.name }}
+
+ {{ product.price | currency : 'USD' }}
+ {{ product.category }}
+
+
+
+
+
+
+
+ In total there are {{ products ? products.length : 0 }} products.
+
+
+
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class TemplateDoc implements OnInit {
+export class TemplateDoc {
products!: Product[];
cols!: Column[];
constructor(private productService: ProductService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData() {
this.productService.getProductsMini().then((data) => {
this.products = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/verticalscrolldoc.ts b/src/app/showcase/doc/table/verticalscrolldoc.ts
index 263b50de847..58659e26fa0 100644
--- a/src/app/showcase/doc/table/verticalscrolldoc.ts
+++ b/src/app/showcase/doc/table/verticalscrolldoc.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { Code } from '../../domain/code';
import { Customer } from '../../domain/customer';
import { CustomerService } from '../../service/customerservice';
@@ -8,35 +8,37 @@ import { CustomerService } from '../../service/customerservice';
template: `
Adding scrollable property along with a scrollHeight for the data viewport enables vertical scrolling with fixed headers.
-
-
-
-
- Name
- Country
- Company
- Representative
-
-
-
-
- {{ customer.name }}
- {{ customer.country.name }}
- {{ customer.company }}
- {{ customer.representative.name }}
-
-
-
-
+
+
+
+
+
+ Name
+ Country
+ Company
+ Representative
+
+
+
+
+ {{ customer.name }}
+ {{ customer.country.name }}
+ {{ customer.company }}
+ {{ customer.representative.name }}
+
+
+
+
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class VerticalScrollDoc implements OnInit {
+export class VerticalScrollDoc {
customers!: Customer[];
constructor(private customerService: CustomerService, private cd: ChangeDetectorRef) {}
- ngOnInit() {
+ loadDemoData() {
this.customerService.getCustomersMedium().then((data) => {
this.customers = data;
this.cd.markForCheck();
diff --git a/src/app/showcase/doc/table/virtualscrolldoc.ts b/src/app/showcase/doc/table/virtualscrolldoc.ts
index 495559cc579..3bbb1c6f04c 100644
--- a/src/app/showcase/doc/table/virtualscrolldoc.ts
+++ b/src/app/showcase/doc/table/virtualscrolldoc.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, Component } from '@angular/core';
import { Car } from '../../domain/car';
import { Code } from '../../domain/code';
import { CarService } from '../../service/carservice';
@@ -16,6 +16,7 @@ interface Column {
suggested to use the same
virtualScrollItemSize value on the tr element inside the body template.
+
@@ -34,10 +35,11 @@ interface Column {
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class VirtualScrollDoc implements OnInit {
+export class VirtualScrollDoc {
cars!: Car[];
virtualCars!: Car[];
@@ -46,7 +48,7 @@ export class VirtualScrollDoc implements OnInit {
constructor(private carService: CarService) {}
- ngOnInit() {
+ loadDemoData() {
this.cols = [
{ field: 'id', header: 'Id' },
{ field: 'vin', header: 'Vin' },
diff --git a/src/app/showcase/doc/table/virtualscrolllazydoc.ts b/src/app/showcase/doc/table/virtualscrolllazydoc.ts
index 7fdc9c34a56..e24c8847528 100644
--- a/src/app/showcase/doc/table/virtualscrolllazydoc.ts
+++ b/src/app/showcase/doc/table/virtualscrolllazydoc.ts
@@ -17,35 +17,37 @@ interface Column {
suggested to use the same
virtualScrollItemSize value on the tr element inside the body template.
-
-
-
-
-
- {{ col.header }}
-
-
-
-
-
-
- {{ rowData[col.field] }}
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+ {{ col.header }}
+
+
+
+
+
+
+ {{ rowData[col.field] }}
+
+
+
+
+
+
+
+
+
+
+
+
+
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class VirtualScrollLazyDoc implements OnInit {
+export class VirtualScrollLazyDoc {
cars!: Car[];
virtualCars!: Car[];
@@ -54,7 +56,7 @@ export class VirtualScrollLazyDoc implements OnInit {
constructor(private carService: CarService) {}
- ngOnInit() {
+ loadDemoData() {
this.cols = [
{ field: 'id', header: 'Id' },
{ field: 'vin', header: 'Vin' },
From 4b49e6b6c1326719e09d2034c8442f556be3b7d2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=87etin?=
<69278826+cetincakiroglu@users.noreply.github.com>
Date: Thu, 4 Jan 2024 10:29:13 +0300
Subject: [PATCH 2/3] Update structure
---
src/app/components/demo/ng-package.json | 6 ------
src/app/components/demo/public_api.ts | 1 -
.../demo/deferreddemo.scss} | 0
.../demo/deferreddemo.ts | 17 ++++-------------
src/app/showcase/doc/table/tabledoc.module.ts | 5 +++--
5 files changed, 7 insertions(+), 22 deletions(-)
delete mode 100644 src/app/components/demo/ng-package.json
delete mode 100644 src/app/components/demo/public_api.ts
rename src/app/{components/demo/deferreddemo.css => showcase/demo/deferreddemo.scss} (100%)
rename src/app/{components => showcase}/demo/deferreddemo.ts (77%)
diff --git a/src/app/components/demo/ng-package.json b/src/app/components/demo/ng-package.json
deleted file mode 100644
index ab5467eb7e4..00000000000
--- a/src/app/components/demo/ng-package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "$schema": "ng-packagr/ng-package.schema.json",
- "lib": {
- "entryFile": "public_api.ts"
- }
- }
\ No newline at end of file
diff --git a/src/app/components/demo/public_api.ts b/src/app/components/demo/public_api.ts
deleted file mode 100644
index 75d9b10f247..00000000000
--- a/src/app/components/demo/public_api.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './deferreddemo';
diff --git a/src/app/components/demo/deferreddemo.css b/src/app/showcase/demo/deferreddemo.scss
similarity index 100%
rename from src/app/components/demo/deferreddemo.css
rename to src/app/showcase/demo/deferreddemo.scss
diff --git a/src/app/components/demo/deferreddemo.ts b/src/app/showcase/demo/deferreddemo.ts
similarity index 77%
rename from src/app/components/demo/deferreddemo.ts
rename to src/app/showcase/demo/deferreddemo.ts
index e8b1cfb3e48..45694fa6f3e 100755
--- a/src/app/components/demo/deferreddemo.ts
+++ b/src/app/showcase/demo/deferreddemo.ts
@@ -1,19 +1,17 @@
import { CommonModule, isPlatformBrowser } from '@angular/common';
-import { Component, ElementRef, EventEmitter, Inject, Input, NgModule, OnInit, Output, PLATFORM_ID } from '@angular/core';
-import { SharedModule } from 'primeng/api';
+import { Component, ElementRef, EventEmitter, Inject, Input, OnInit, Output, PLATFORM_ID } from '@angular/core';
@Component({
selector: 'p-deferred-demo',
+ standalone: true,
+ imports: [CommonModule],
template: `
Loading...
`,
- styleUrls: ['./deferreddemo.css'],
- host: {
- class: 'p-element'
- }
+ styleUrl: './deferreddemo.scss'
})
export class DeferredDemo implements OnInit {
visible: boolean = false;
@@ -52,10 +50,3 @@ export class DeferredDemo implements OnInit {
clearTimeout(this.timeout);
}
}
-
-@NgModule({
- imports: [CommonModule, SharedModule],
- exports: [DeferredDemo, SharedModule],
- declarations: [DeferredDemo]
-})
-export class DeferredDemoModule {}
diff --git a/src/app/showcase/doc/table/tabledoc.module.ts b/src/app/showcase/doc/table/tabledoc.module.ts
index 36925424477..5bc4c656249 100644
--- a/src/app/showcase/doc/table/tabledoc.module.ts
+++ b/src/app/showcase/doc/table/tabledoc.module.ts
@@ -81,7 +81,8 @@ import { StylingDoc } from './stylingdoc';
import { SelectionEventsDoc } from './selectioneventsdoc';
import { AccessibilityDoc } from './accessibilitydoc';
import { PaginatorLocaleDoc } from './paginatorlocaledoc';
-import { DeferredDemoModule } from 'primeng/demo';
+import { DeferredDemo } from '../../demo/deferreddemo';
+
@NgModule({
imports: [
CommonModule,
@@ -113,7 +114,7 @@ import { DeferredDemoModule } from 'primeng/demo';
SelectButtonModule,
AppCodeModule,
AppDocModule,
- DeferredDemoModule
+ DeferredDemo
],
declarations: [
ImportDoc,
From 30507a3208ca74d9c5d0d8b61567f747dbdd8d63 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=87etin?=
<69278826+cetincakiroglu@users.noreply.github.com>
Date: Thu, 4 Jan 2024 10:46:53 +0300
Subject: [PATCH 3/3] Refactor
---
src/app/showcase/demo/deferreddemo.ts | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/app/showcase/demo/deferreddemo.ts b/src/app/showcase/demo/deferreddemo.ts
index 45694fa6f3e..c4f76e9fbc6 100755
--- a/src/app/showcase/demo/deferreddemo.ts
+++ b/src/app/showcase/demo/deferreddemo.ts
@@ -6,10 +6,11 @@ import { Component, ElementRef, EventEmitter, Inject, Input, OnInit, Output, PLA
standalone: true,
imports: [CommonModule],
template: `
-
Loading...
-
-
-
+ @if(!visible){
+
Loading...
+ } @else {
+
+ }
`,
styleUrl: './deferreddemo.scss'
})
@@ -43,6 +44,7 @@ export class DeferredDemo implements OnInit {
this.observer.observe(this.el.nativeElement);
}
}
+
ngOnDestroy() {
if (!this.visible && this.el.nativeElement) {
this.observer?.unobserve(this.el.nativeElement);