import { Component } from '@angular/core';
@Component({
selector: 'inline-edit-demo',
template: `
`
})
export class InlineEditComponent {
editing = {};
rows = [];
constructor() {
this.fetch((data) => {
this.rows = data;
});
}
fetch(cb) {
const req = new XMLHttpRequest();
req.open('GET', `assets/data/company.json`);
req.onload = () => {
cb(JSON.parse(req.response));
};
req.send();
}
updateValue(event, cell, cellValue, row) {
this.editing[row.$$index + '-' + cell] = false;
this.rows[row.$$index][cell] = event.target.value;
}
}