M
M
Maxim Ivanov2016-08-03 15:21:17
Angular
Maxim Ivanov, 2016-08-03 15:21:17

How to display a material light menu that is generated dynamically?

Menus taken from here:
https://getmdl.io/components/index.html#menus-section
Here is the code that generates the menu:

<div class="demo-card-event mdl-card mdl-shadow--2dp" ng-repeat="exemplers in modelExemplersLists">
         
                <button id="demo-menu-top-right-{{ exemplers.id }}"
                        class="mdl-button mdl-js-button mdl-button--icon">
                  <i class="material-icons">more_vert</i>
                </button>
            
                <ul class="mdl-menu mdl-menu--top-right mdl-js-menu mdl-js-ripple-effect"
                    data-mdl-for="demo-menu-top-right-{{ exemplers.id }}">
                  <li class="mdl-menu__item">Редактировать</li>
                  <li class="mdl-menu__item">Удалить</li>
                </ul>

              </div>
            </div>

modelExemplersLists - empty at first, it appears when the server returns JSON
, but in the end, angular renders everything, and the menu is already inactive
0a10b59ee3544508aff268951ed5195e.png
. Unfortunately, for some reason, the dom tree is drawn several times because of this
dataService.getModelExemplarsList(model.id, function(data){

      $scope.modelExemplersLists = data.exemplars;

      angular.element(document).ready( 
        function() {
          componentHandler.upgradeAllRegistered();
      });

});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Максим Иванов, 2016-08-03
@splincodewd Автор вопроса

Пока работает это

angular.element(document).ready( 
      function() {
        componentHandler.upgradeAllRegistered();
    });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question