Skip to content
This repository was archived by the owner on Jan 27, 2022. It is now read-only.
This repository was archived by the owner on Jan 27, 2022. It is now read-only.

Problem with components that are created with component factory resolver #773

Description

@ayberkaltuntabak

Description:
First of all, I am very happy to hear that we have official dev tool support. The bug is that I can't inspect components which i init with component factory resolver in mat-drawer-content component at components side of dev tools.
...

Angular Devtools version (required): 1.0.0

Angular version (required): 11.0.9

Date: 19.05.2021 GMT +03:00

OS: Windows 10 Home 10.0.19042

Demo test application:

  • Git repository for demo app showing the issue (optional but very helpful for difficult issues).
  • If a code snippet will completely show the issue, please include it.

Typescript file.

import{CustomButtonComponent}from'./../custom-button/custom-button.component';import{Component,Input,OnInit,OnChanges,ViewChild,ViewContainerRef,ComponentFactoryResolver,Output,EventEmitter,ChangeDetectorRef}from'@angular/core';import{Menu}from'src/models/menu/Menu';import{ButtonConfig}from'src/models/ButtonConfig';import{UserManagementComponent}from'../user-management/user-management.component';import{ActivityComponent}from'../activity/activity.component';import{DashboardComponent}from'../dashboard/dashboard.component';import{PolicyComponent}from'../policy/policy.component';import{UserSettingsComponent}from'src/app/user-settings/user-settings.component';import{AlertsComponent}from'src/app/alerts/alerts.component';
@Component({selector: 'app-custom-sidenav-menu',templateUrl: './custom-sidenav-menu.component.html',styleUrls: ['./custom-sidenav-menu.component.scss']})exportclassCustomSidenavMenuComponentimplementsOnInit{
@ViewChild("buttonArea",{read:ViewContainerRef})buttonArea:ViewContainerRef|any;
@Input()menuCollection!:Menu[]|any;
@Output()buttonSelected=newEventEmitter<any>();cleanMenuCollection : Menu[]|anybuttonConfig: never[]|any;componentMap!:anyselectedMenu: ButtonConfig;constructor(privatecomponentFactoryResolver:ComponentFactoryResolver,privatecdr : ChangeDetectorRef){this.componentMap={"Users":UserManagementComponent,"Activity":ActivityComponent,"Policy":PolicyComponent,"Dashboard":DashboardComponent,"User Settings":UserSettingsComponent,"Alerts": AlertsComponent}}ngOnInit(): void{}ngOnChanges(menuCollection:Menu[]|any){}ngAfterViewInit(){this.cleanMenuCollection=[];this.menuCollection.forEach((menuTemp:Menu)=>{letfoundMenuItemsInBefore :any=this.cleanMenuCollection.find((data :Menu|any)=>{if(menuTemp.type==data.type){returndata;}})if(foundMenuItemsInBefore==undefined){this.cleanMenuCollection.push(menuTemp)}});this.createButtons();}createButtons(){this.buttonArea?.clear();this.buttonConfig=this.cleanMenuCollection.map((data:Menu)=>{letkey :any=this.componentMap[data.type];letobj={icon:data.icon,buttonClass:"btn-transparent",status:"passive",click:(event:any)=>this.clickOnMenu(event),text:data.type,menuComponent:key}letcompRef=this.componentFactoryResolver.resolveComponentFactory(CustomButtonComponent);letcomp=this.buttonArea.createComponent(compRef);comp.instance.config=objreturnobj})letdashboardButton=this.buttonConfig.find(config=>config.text=='Dashboard');dashboardButton.buttonClass="btn-transparent menu-active"this.buttonSelected.emit(dashboardButton.menuComponent)this.cdr.detectChanges();}clickOnMenu(event:any){this.buttonConfig=this.buttonConfig.map((menuItem:ButtonConfig)=>{if(event.config!=menuItem){menuItem.buttonClass='btn-transparent';}else{menuItem.buttonClass="btn-transparent menu-active"if(this.selectedMenu?.text!=menuItem.text){this.selectedMenu=menuItemthis.buttonSelected.emit(menuItem.menuComponent)}}returnmenuItem})}// this.navbarButton = { icon: 'fas fa-bars', buttonClass: 'btn-transparent', status: "passive", click: (event: any) => this.navbarClick(event) }getKeyByValue(object: {[x: string]: any;},value: any){returnObject.keys(object).find(key=>object[key]===value);}}

Html File

<divclass="application-container w-100 h-100"><mat-drawer-containerclass="example-container h-100 w-100"><mat-drawerclass="mat-container" #sidenavmode="side" style="width: 15%;"><divclass="d-flex flex-column align-items-center justify-content-between p-2 overflow-hidden"><divclass="header w-100"><spanclass="header-text fs-4 w-100">
{{this.user?.honeypot?. name}}
</span></div><ng-container#sidenavArea></ng-container></div></mat-drawer><mat-drawer-contentclass="component-area"><ng-container#componentArea></ng-container></mat-drawer-content></mat-drawer-container></div>

Description of issue:

Capture

As you may see that components that should be produced ,are not shown.

I appericiate your attention on this spesific problem in advance.

Metadata

Metadata

Assignees

Labels

P3bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions