angularjs - Recommend design for dynamic ionic side menu -


my app has many states falls under different categories , need different side menus each category.

/book/view /book/edit .. /dvd/buy /dvd/view ..etc 

i have 3 options:

1. using different menus templates:

    $stateprovider                                              .state('dvd', {                                                 url: '/dvd',                                                abstract: true,                                             templateurl: 'templates/dvd_menu.html',                         controller: 'appctrl'                                   })                                                            .state('book', {                                                 url: '/book',                                                abstract: true,                                             templateurl: 'templates/book_menu.html',               controller: 'appctrl'                                   })                                                  

using this, couldn't figure out enable button show if switch books dvds.

2. populating menu dynamically:

    <ion-item               menu-close              ng-click="$eval(item.click)"              ng-repeat="item in custommenuitems track $index">         {{item.text}}     </ion-item> 

is solution recommended?

3. putting items in menu , switch them on , off using ng-show.

is there better solution missing, how it?

it depends on choice.

for me, creating controller can take categoryid , actionid parameters.

  1. register in app.js:

    $stateprovider                                      .state('category', {                                         url: '/category/:categoryid/:actionid',                                   templateurl: 'templates/category.html',                 controller: 'categoryctrl'                           }) 
  2. create categoryservice handle items each category, example had getitems method takes categoryid , actionid , return list of items. inject categoryctrl:

    myapp.controller('categoryctrl', ['$scope', '$stateparams', 'categoryservice',       function($scope, $stateparams, categoryservice){          var categoryid = $stateparams.categoryid;          var actionid = $stateparams.actionid;              $scope.custommenuitems = categoryservice.getitems(categoryid, actionid); }); 
  3. bind custommenuitems templates/category.html view through $scope.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -