Last active
July 4, 2019 20:22
-
-
Save lossendae/8409675 to your computer and use it in GitHub Desktop.
Dynamic (single level) menu for Angular ui-router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app> | |
<head> | |
<title>Example</title> | |
</head> | |
<body> | |
<nav class="main-nav" data-main-menu data-root="index"></nav> | |
<script type="text/javascript" src="angular.js"></script> | |
<script type="text/javascript" src="ui.router.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* In my main config module */ | |
// Shown in menu | |
$stateProvider | |
.state('index', { | |
url: "/", | |
menu : { | |
title : 'Dashboard', | |
icon : 'fa-home' | |
} | |
}); | |
/* In another config module */ | |
$stateProvider | |
// Not shown in menu | |
.state('index.item', { | |
url: "/item" | |
}) | |
// Show in menu | |
.state('index.item.child', { | |
url: "/child1", | |
abstract: true | |
menu : { | |
title : 'A menu item', | |
state : 'index.item.child.grandchild' // Point to children | |
} | |
}) | |
// Not shown in menu but a menu item point to it | |
.state('index.item.child.grandchild', { | |
url: "" | |
}) | |
// Not shown in menu | |
.state('index.item.child.grandchild2', { | |
url: "/child2" | |
}); |
in state.js on line 24, what is going on with the syntax? isn't there a comma missing on line 23? and, i don't see a "menu" property available in the API, per the documentation: http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$stateProvider
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what is "commons"?