I have service that gets me array of types:
ngOnInit() {
this.coreService.getByType( this.name ).subscribe(
response => { this.handleSuccess( response ); },
error => { console.error( error ); });
}
handleSuccess( coreTypes ) {
var data = [];
var pushedItems = [];
coreTypes.forEach( ( coreType ) => {
var entriesForType = [];
entriesForType.push( coreType );
if ( entriesForType.length > 0 ) {
entriesForType.forEach( entry => this.data.push( entry ) );
this.data = data;
if (data.length > 0) {
data.forEach( d => this.item.value = d && pushedItems.push(this.item));
}
if(this.gridOptions.api !== null){
this.gridOptions.api.setRowData( this.pushedItems );
}
}
});
}
Currently, this.data is creating me array like this this.data = ["one","two","three"]
What i need is to create array of object that will look like this
pushedItems = [{value:"one"},{value:"two"},{value:"three"}];
I defined item: Object; and in contstructor this.item = {value:""};
But in function, when i set this.item.value = d ... it keeps showing me error "Property 'value' does not exist on type 'Object' ...Any help to achieve array like pushedItems?
subscribe( (response:any)=> { this.handleSuccess( response ); });