How to initiate MixItUp with AngularJS NgRoute

前端 未结 4 989
囚心锁ツ
囚心锁ツ 2021-01-18 07:55

I\'ve been setting up a jquery plugin MixItUp with AngularJS and although I can successfully initiate the container during one of my partial views with NgRoute, once I move

4条回答
  •  情话喂你
    2021-01-18 08:14

    I spent several hours and finally the solution is here....

    if ($('#grid').mixItUp('isLoaded')) {
              $('#grid').mixItUp('destroy');
              $('#grid').mixItUp();
          } else {
            $('#grid').mixItUp();
          }
    

    Here's the full directive code..

    'use strict';
     angular.module('rjApp')
    .directive('mixitup',function($timeout,$compile){
      var linker = function(scope,element,attr) {
    
        scope.$watch('entities', function(newVal, oldVal){
    
          $timeout(function(){
            if ($('#grid').mixItUp('isLoaded')) {
                $('#grid').mixItUp('destroy');
                $('#grid').mixItUp();
            } else {
              $('#grid').mixItUp();
            }
          },10);
        },true);
    
      };
      return {
        link: linker,
        scope:{entities:'='}
      }
    })
    

提交回复
热议问题