No component factory found when i call NbWindow from Custom Button Ng2-SmartTable
- Dominant language
- TypeScript
- Stars
- 8.1k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
### Issue type
**I'm submitting a ...** (check one with "x")
* [X ] bug report
* [ ] feature request
### Issue description
**Current behavior:**
**Expected behavior:**
When i call the NbWindow from a event click of one custom button into Ng2-smart-table i have the error 'No component factory found for MyComponent'. If I change the NbWindows in NbDialog all works fine.
Specific error(view code):
`No component factory found for RoleWindowUserComponent. Did you add it to @NgModule.entryComponents?
at noComponentFactoryError (core.js:7754)
at CodegenComponentFactoryResolver.push../node_modules/@angular/core/fesm5/core.js.CodegenComponentFactoryResolver.resolveComponentFactory (core.js:7792)
at NbPortalOutletDirective.push../node_modules/@angular/cdk/esm5/portal.es5.js.CdkPortalOutlet.attachComponentPortal (portal.es5.js:647)
at NbOverlayContainerComponent.push../node_modules/@nebular/theme/components/cdk/overlay/overlay-container.js.NbOverlayContainerComponent.attachComponentPortal (overlay-container.js:87)
at NbWindowComponent.push../node_modules/@nebular/theme/components/window/window.component.js.NbWindowComponent.attachComponent (window.component.js:105)
at NbWindowComponent.push../node_modules/@nebular/theme/components/window/window.component.js.NbWindowComponent.ngAfterViewChecked (window.component.js:64)
at callProviderLifecycles (core.js:18940)
at callElementProvidersLifecycles (core.js:18911)
at callLifecycleHooksChildrenFirst (core.js:18901)
at checkAndUpdateView (core.js:19837)`
**Related code:**
user.component.ts (User Manage Component)
`
@Component({
selector: 'role-button',
template: '',
})
export class RoleButtonComponent implements ViewCell, OnInit {
@Input() value: string | number;
@Input() rowData: any;
// @ViewChild('dgRole') dgRole: TemplateRef;
constructor(private _windowService: NbWindowService, private _userManage: UsersmanageService) {
}
ngOnInit() {
console.log(this.value);
}
getAllRoles() {
return this._userManage.GetAllRoles()
.subscribe((response) => {
return response;
});
}
onClick() {
this._windowService.open(
RoleWindowUserComponent, {
title: 'Assign Roles to ' + this.rowData.fullName,
context: {
/*userID: this.rowData.id,
actualRoles: this.rowData.roles,
allRoles: this.getAllRoles(),*/
},
},
);
}
}
@Component({
selector: 'users',
templateUrl: './users.component.html',
styleUrls: ['./users.component.scss'],
})
export class UsersComponent implements OnInit {
users: Users = {};
isUsersLoading: boolean;
settings = {
columns: {
id: {
title: 'ID',
filter: true,
editable: false,
},
fullName: {
title: 'Full Name',
filter: true,
},
email: {
title: 'Email',
filter: true,
editable: false,
},
active: {
title: 'Active',
filter: false,
},
created_at: {
title: 'Created At',
filter: true,
editable: false,
},
addRoles: {
title: 'Roles',
filter: false,
editable: false,
type: 'custom',
renderComponent: RoleButtonComponent,
},
},
add: {
addButtonContent: '',
createButtonContent: '',
cancelButtonContent: '',
},
edit: {
editButtonContent: '',
saveButtonContent: '',
cancelButtonContent: '',
},
delete: {
deleteButtonContent: '',
confirmDelete: true,
},
};
source: LocalDataSource;
constructor(private _userManage: UsersmanageService, private _toastrService: ToastrService) {
}
ngOnInit() {
this.isUsersLoading = true;
this._userManage.GetAllUsers()
.subscribe(res => {
this.source = new LocalDataSource(res.body as Array);
this.isUsersLoading = false;
}, error => {
this.isUsersLoading = false;
console.log(error);
this.isUsersLoading = false;
});
}
}`
role-dialog(Window Component for assign role to user)
`
@Component({
selector: 'role-window-user',
templateUrl: './role-window-user.component.html',
styleUrls: ['./role-window-user.component.scss']
})
export class RoleWindowUserComponent implements OnInit {
constructor() { }
ngOnInit() {
console.log(this);
}
}`
admin.module.ts(module)
`const COMPONENT = [
AdminComponent,
UsersComponent,
RolesComponent,
PermissionsComponent,
RoleButtonComponent,
];
const PARTIALS = [
RoleButtonComponent,
];
@NgModule({
declarations: [
...COMPONENT,
RoleWindowUserComponent,
],
entryComponents: [
...PARTIALS,
RoleWindowUserComponent
],
imports: [
ThemeModule,
CommonModule,
NgxPaginationModule,
AdminRoutingModule,
Ng2SmartTableModule,
],
})
export class AdminModule {
}
`
### Other information:
**npm, node, OS, Browser**
`npm --version 6.4.1
node --version 10.13.0`
**Angular, Nebular**
` "@angular/core": "^7.0.3",
"@nebular/auth": "^3.4.0",
"@nebular/bootstrap": "^3.4.0",
"@nebular/security": "^3.4.0",
"@nebular/theme": "^3.4.0",
"ng2-completer": "^3.0.0-beta.2",
"ng2-smart-table": "^1.4.0",`
Contributor guide
Assessment
This issue has not been assessed yet.