Closed d668 closed 8 years ago
Hi, sorry ! I didn't update the documentation yet. With other user's pull-request, we've changed some of the original implementation.
You should look at demo code
i've looked through the example and still don't get how do I select a menu item. Because if my user logs in, I want to change the menu and show him some specific item. And with the current project seems like i can do it only if i use ssSideNavSectionsProvider.initWithSections
one, you config your menu using provider ssSideNavSectionsProvider.initWithSections in app.config.
inWithSections(array), the array contains menu item (an object keys/values) in where you can add a key hidden
example:
{ id: 'link_3', name: 'Link 3', state: 'common.link3', type: 'link', hidden: true }
by default, hidden
is set to false if you not provided
then, if you want to hide/show, use setVisible(id, value)
=> setVisible('link_3', true) in your controller.
If you want to replace all of the menu items config, in your controller, you can do ssSideNav.sections = [{//new item}, {//new item}, etc]
thanks for the explanation, but I still don't understand if selectSection is deprecated, what is a replacement? setVisible doesn't open the menu. Also initializing menu at config is too early for me
any update here please? How to open children menu programmatically?
mm selectSection is not intend to be used like that.
if you want to open children menu, it basically means that you change the url (state) in your app. So to do that, you just have to change your state. e.g:
$state.go('common.toggle1.item2')
which result to load the url /item2, which will open the dropdown menu "toggle1" in the demo app
i guess this may work if the menu is initiated in config, but if I assign sections
ssSideNav.sections = menuForSomeRole;
it doesn't work when using ui-sref or $state.go
I have several roles and i assign menu dynamically. Is your lib supposed to work only with one menu?
Thanks
yes, you can change the entire menu as you want, but it appears, that it does not actually open the dropdown section when sub item is selected, i'm working on it
ok cool. thanks
i've pushed a new version. You can now do ssSideNav.forceSelectionWithId('ID');
which results to select the child item on an dropdown menu sections and select its state name.
Let me know if its works for you.
thx.
is appears working, although inside controller i have to put it inside $timeout
$timeout(function () { ssSideNav.forceSelectionWithId(vm.stateName); }, 100);
And what is supposed styling of a selected menu item?
thank you!
I assume ssSideNav.selectSection should open a section? I am adding following code to _common.js