I'm busy working with the angularSlickgrid library on an Angular project. I created a dropdown component to use inside my grid but here is the problem ... When I try to import the component and call it without a constructor it loads and the dropdrown creates fine.. but as soon as I try to load the same component via its constructor I get the following error :
"Error: Uncaught (in promise): Error: No component factory found for [object Object]. Did you add it to @NgModule.entryComponents?
I've already made sure my imports are correct here is the relevant parts of my autenticated.module.ts :
import { CrmGridViewComponent } from './crm/crmGridListView/crnm-grid-view/crnm-grid-view.component';
import { GridDropDownCreator } from './components/gridDropdownComponent/gridDropDown';
declarations: [
CrmGridViewComponent,
GridDropDownCreator,
],
entryComponents: [
GridDropDownCreator,
CrmGridViewComponent,
]
Now like I said if the dropdown component doesn't have a constructor it works... dropdown :
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-dropdown',
template: `
<div id="{{dropdownId}}" class="dropdown" style="position:absolute; z-index:12000;">
<a class="dropdown-toggle"
id="{{dropDownToggleId}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Actions
<span class="caret"></span>
</a>
<ul class="dropdown-menu padding10">
<li><span class="text-primary text-center" >{{dataContext.title}}</span></li>
<li role="separator" class="divider"></li>
<li><span class='pointer'>View contacts</span></li>
<li><span class='pointer'>Edit</span></li>
<li><span class='pointer'>Delete</span></li>
</ul>
</div>`,
//templateUrl: './dropdown.component.html',
})
export class GridDropDownCreator {
// constructor(labelFor: string) { //uncommented is wat I actually want to achieve.. this is a test for bigger data to come
// console.log('the constructor fired : ');
// }
parent: any; // parent component context
row: number;
dataContext: any;
dropdownId = 'companyDropDown';
dropDownToggleId = 'toggleDrop';
}
here is where I try to access the component :
import { Column, GridOption, AngularUtilService, Formatters, AngularGridInstance, BsDropDownService, OnEventArgs } from 'angular-slickgrid';
import { GridDropDownCreator } from 'pathToFile/gridDropdownComponent/gridDropDown';
prepareGrid() {
this.columnDefinitions = [
// ['name', 'surname', 'telNr', 'cellNr', 'email', 'tags', 'options'];
{ id: 'name', name: 'Name', field: 'name', sortable: true, filterable: true, },
{ id: 'category', name: 'Category', field: 'category', sortable: true, filterable: true },
{ id: 'vatNo', name: 'vatNo', field: 'vatNo', sortable: true, filterable: true },
{ id: 'description', name: 'Description', field: 'description', sortable: true, filterable: true },
{ id: 'tags', name: 'Tags', field: 'tags', sortable: true, filterable: true },
{
id: 'action',
name: 'Action',
field: 'id',
formatter: Formatters.bsDropdown,
params: { label: 'Action' },
onCellClick: (e: Event, args: OnEventArgs) => {
// const comp = new GridDropDownCreator('company'); //this is what I want but it doesn't work this way
this.bsDropdown.render({
component: comp, //change this to the imported dropdown (GridDropDownCreator) and comment out the constructor and it will display the dropdown
args,
offsetLeft: 92,
offsetDropupBottom: 15,
parent: this, // provide this object to the child component so we can call a method from here if we wish
});
},
// exportCustomFormatter: Formatters.complexObject,
// asyncPostRender: this.renderAngularComponent.bind(comp),
}
];
this.gridOptions = {
enableAutoResize: true,
enableSorting: true,
enableColumnReorder: false,
enableFiltering: true,
enablePagination: true,
enableAsyncPostRender: true,
asyncPostRenderDelay: 0,
rowHeight: 50,
rowSelectionOptions: {
// True (Single Selection), False (Multiple Selections)
selectActiveRow: false
},
params: {
angularUtilService: this.angularUtilService // provide the service to all at once (Editor, Filter, AsyncPostRender)
}
};
// fill the dataset with your data
this.dataset = [ /** ...your data... **/];
}
To Sumarize the question how Do I call the GridDropDownCreator via is constructor ? without it giving me this error : "Error: Uncaught (in promise): Error: No component factory found for [object Object]. Did you add it to @NgModule.entryComponents?
thanks guys!