here i'm setting up for dynamic menu from database having recursive structure. menu appears in other pages but raised an error in side navbar, there is any way to implement?
i have created one custom components and its working fine in all pages but not working into side navigation bar. when i put custom components into side navigation bar, then its raised an error like this.
compiler.js:2430 Uncaught Error: Template parse errors:
Can't bind to 'ngClass' since it isn't a known property of 'i'. ("ngFor="let parentNode of DynamicMenuList">
<a *ngIf="parentNode.Path == ''" href="">
<i [ERROR ->][ngClass]="parentNode.icon"></i><span> {{ parentNode.text }}</span>
<i *ngIf="parentNode.subme"): ng:///MenuViewModule/TreeView.html@28:9
Can't bind to 'ngIf' since it isn't a known property of 'i'. ("'" href="">
<i [ngClass]="parentNode.icon"></i><span> {{ parentNode.text }}</span>
<i [ERROR ->]*ngIf="parentNode.submenu != null" class="fa fa-angle-left"></i>
</a>
here is menu-view.module.ts that return the custom components to layout module
import { NgModule } from '@angular/core';
import { MenuViewComponent } from './menu-view.component';
import { TreeView } from './tree-view.directory';
@NgModule({
declarations: [
MenuViewComponent,
TreeView,
],
exports: [
MenuViewComponent,
TreeView,
]
})
export class MenuViewModule { }
here is my layout.module.ts
import { NgModule } from '@angular/core';
.......
.......
import { MenuViewModule } from '../menu-view/menu-view.module';
import { LayoutSidenavComponent } from './layout-sidenav/layout-sidenav.component';
@NgModule({
imports: [
......
......
NgbModule,
SidenavModule,
MenuViewModule
],
declarations: [
......
LayoutNavbarComponent,
LayoutSidenavComponent,
LayoutFooterComponent
],
providers: [
LayoutService
]
})
export class LayoutModule { }
here is my custom components code
<ul class="sidebar-menu">
<li class="treeview" *ngFor="let parentNode of DynamicMenuList">
<a *ngIf="parentNode.Path == ''" href="">
<i [ngClass]="parentNode.icon"></i><span> {{ parentNode.text }}</span>
<i *ngIf="parentNode.submenu != null" class="fa fa-angle-left"></i>
</a>
<a *ngIf="parentNode.Path != ''" [routerLink]="[parentNode.Path]">
<i [ngClass]="parentNode.icon"></i><span> {{ parentNode.text }}</span>
<i *ngIf="parentNode.submenu != null" class="fa fa-angle-left"></i>
</a>
<ul class="treeview-menu">
<li *ngFor="let childNode of parentNode.submenu">
<a [routerLinkActive]="['active']">
<i [ngClass]="childNode.icon"></i><span>{{childNode.text}}</span>
<i *ngIf="childNode.submenu != null" class="fa fa-angle-left"></i>
</a>
<div *ngIf="childNode.submenu.length > 0" class="treeview-menu">
<tree-view [DynamicMenuList]="childNode.submenu"></tree-view>
</div>
</li>
</ul>
</li>
</ul>
i actually need menuview into side navigation but its not return, when i put it into other page just
then its provide me perfect output like this.here is my output : https://i.sstatic.net/S5guc.jpg
CommonModulein a module of you own. Maybe the layout module.CommonModulebut not added into MenuViewModule, after addingCommonModulethere is another issues like this.Uncaught Error: Template parse errors: 'tree-view-menu' is not a known element: 1. If 'tree-view-menu' is an Angular component, then verify that it is part of this module.