I am working with a person array that I have displayed in a Primeng datatable. Each object in the array has fields for first name, last name, and age, which are represented as columns in the table. Additionally, there is a column to display the status of each object, indicating if any changes have been made (either "Object Change" or "Not Change").
https://i.sstatic.net/S31fR.jpg
<p-dataTable [value]="persons" [editable]="true" resizableColumns="true" reorderableColumns="true">
<p-column header="Status">
<ng-template pTemplate="body">
<span [hidden]=true>Object Change</span>
<span >Not Change</span>
</ng-template>
</p-column>
<p-column field="firstName" header="First Name" [editable]="true"></p-column>
<p-column field="lastName" header="Last Name" [editable]="true"></p-column>
<p-column field="age" header="Age" [editable]="true">
<ng-template let-col let-car="rowData" pTemplate="editor">
<select class="form-control" [(ngModel)]="car[col.field]">
<option [value]=12>12</option>
<option [value]=14>14</option>
<option [value]=23>23</option>
</select>
</ng-template>
</p-column>
</p-dataTable>
<p>{{persons | json}}</p>
The columns in the datatable are editable to allow users to modify the data. Now, I am looking for a way to detect if any changes have been made to an object in the array. If there are changes, I want the status column to indicate "Object change". This condition should be checked for each row/object in the array. I have created a Plunker example for reference: http://plnkr.co/edit/x8Sdgz?p=preview