New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MetisMenu Angular 2 - not working on first load #114
Comments
This worked for me first declare jquery after your imports replace this: with this: |
Thanks kabayan @robertdelacruz1551. |
Thank you. I'm adapted from
to
|
i met the similar problem. |
@BlankHrt - I appear to be having the same problem. In my case the error is:
I am using Angular: |
@fir3pho3nixx sorry i haven't solve the problem yet. I dropped it |
@BlankHrt - Me neither. In the end I built a vanilla Angular 4 component: Dependencies:
Component: <div class="navbar-default sidebar" role="navigation">
<div class="sidebar-nav navbar-collapse">
<ul class="nav" id="side-menu">
<li *ngFor="let menu of menuDefinition">
<!-- Top level menu -->
<a href="{{menu.href}}"
*ngIf="!menu.children || menu.children.length == 0">
<i class="fa {{menu.icon}}"></i>{{menu.text}}
</a>
<!-- Top level menu with children -->
<a href="{{menu.href}}"
*ngIf="menu.children && menu.children.length > 0"
(click)="menu.expanded=!menu.expanded;false;"
[attr.aria-expanded]="menu.expanded"
aria-controls="{{menu.childMenuId}}">
<i class="fa {{menu.icon}}"></i>{{menu.text}}
<span [ngClass]="{'fa-rotate-270': menu.expanded}" class="fa arrow fa-rotate-270"></span>
<ul id="{{menu.childMenuId}}"
[ngbCollapse]="!menu.expanded"
class="nav nav-second-level">
<li *ngFor="let childMenu of menu.children">
<a href="{{childMenu.href}}">{{childMenu.text}}</a>
</li>
</ul>
</a>
</li>
</ul>
</div>
</div> import {
Component,
AfterViewInit
} from '@angular/core';
@Component({
selector: 'navigation',
templateUrl: './navigation.component.html',
styleUrls: ['./navigation.component.css']
})
export class NavigationComponent implements AfterViewInit {
menuDefinition: Array<any> = [{
text: 'Dashboard',
icon: 'fa-dashboard fa-fw',
href: '#'
}, {
text: 'Charts',
icon: 'fa-bar-chart-o fa-fw',
href: '#',
expanded: true,
childMenuId: 'chartsLinks',
children: [{
text: 'Flot Charts',
href: '#'
}, {
text: 'Morris.js Charts',
href: '#'
}]
}, {
text: 'Tables',
icon: 'fa-table fa-fw',
href: '#'
}, {
text: 'Forms',
icon: 'fa-edit fa-fw',
href: '#'
}, {
text: 'UI Elements',
icon: 'fa-wrench fa-fw',
href: '#',
expanded: true,
childMenuId: 'uiLinks',
children: [{
text: 'Panels and Wells',
href: '#'
}, {
text: 'Buttons',
href: '#'
}, {
text: 'Notifications',
href: '#'
}, {
text: 'Typography',
href: '#'
}, {
text: 'Icons',
href: '#'
}, {
text: 'Grid',
href: '#'
}]
}];
ngAfterViewInit(): void {
}
} |
You can choose another menu or write your own menu . |
Worked for me to! |
metisMenu not working on initial or first load. After refresh it works fine,
My app.component.ts looks like this,
My menu items looks like this,
I'm not getting any error. All the menu items are expanded by default on the first load. When I click on the head item, the page gets refreshed and all the menu items are collapsed and everything works fine from then on...
The text was updated successfully, but these errors were encountered: