у меня есть два компонента, в первом у меня есть вход массива
первый компонент:
@Input('data')
set ungroupedData(ungroupedData: any[]) {
this._ungroupedData = null;
this.groupedData = [];
this._ungroupedData = ungroupedData;
this.columnManager = [];
this.cdr.detectChanges();
if (ungroupedData) {
this.jsonKeys = Object.keys(this.ungroupedData[0]);
let groupBy: string = this.jsonKeys[0] ? this.jsonKeys[0] : "";
if (this.groupingColumn && this.groupingColumn.length > 0) {
groupBy = this.groupingColumn;
}
this.groupedData = this.groupStructural(groupBy, this.ungroupedData);
this.groupKeys = Object.keys(this.groupedData);
// Fill columnContainer
for (var groupKey of this.groupKeys) {
var x: ColumnContainer = new ColumnContainer();
x.add([{
jsonKey: this.displayColumn,
name: groupKey,
width: 90,
type: EColumnType.text,
clickable: EColumnClickable.clickable,
routerURL: '/bulletin-officiel/access-chronologique/detail/',
routerKey: 'tid',
sortable: false,
order: 0
},
{
jsonKey: "pdf",
name: "PDF",
width: 10,
type: EColumnType.icon,
clickable: EColumnClickable.clickable,
imageURL: "/assets/projets/images/pdf.png",
sortable: false,
order: 1
}]);
this.columnManager.push(x);
}
} else {
this._ungroupedData = null;
}
this.cdr.detectChanges();
}
@Input('groupBy') groupingColumn: string;
@Input('display') displayColumn: string;
private _groupedData: any;
public get groupedData() {
return this._groupedData
};
public set groupedData(newData: any) {
this._groupedData = [];
this.cdr.detectChanges();
this._groupedData = newData;
}
public jsonKeys: string[];
public groupKeys: string[];
private columnManager: ColumnContainer[];
constructor(private cdr: ChangeDetectorRef) {
this.columnManager = [];
}
В представлении второго компонента я вызываю первый и передаю данные ему так.
<app-dynamic-tree [data]="data" groupBy="label" display="ttitreLFr"></app-dynamic-tree>
<div style="position: fixed; top: 50%; right: 50%">
<ngx-spinner bdColor="trasparent"
size="medium"
color="#2288bd"
type="ball-clip-rotate"></ngx-spinner>
</div>
Был вызван API, но вид первого компонента не обновляется. Я не знаю, что именно является источником проблемы.
Интересно, есть ли какое-то решение?
большое спасибо.