MixItUp带有AngularJs的下拉过滤器?

时间:2015-11-06 09:35:20

标签: angularjs mixitup

我正在尝试将MixItUp与AngularJS一起使用,它可以正常使用按钮,但是当尝试使用下拉按钮时它不会。

<select class="filter" ng-model="selectedCategory"
        ng-options="'.' + cat.id as cat.name for cat in categories track by cat.id">
    <option value="">-- Category --</option>
</select>
<pre>{{ selectedCategory }}</pre>

<div mix-it-up class="container">
    <div class="mix {{widget.categoryId}}" data-myorder="{{widget.name}}" 
         ng-repeat="widget in widgets">
                  {{widget.name}}
    </div>
    <div class="gap"></div>
    <div class="gap"></div>
</div>

http://jsfiddle.net/dp31o591/2/

1 个答案:

答案 0 :(得分:0)

我想出这个。只需要在变更时使用该事件:

HTML:

<select class="form-control" ng-model="category" ng-change="filterCategory(category)"
ng-options="'.cat' + cat.id as cat.name for cat in categories track by cat.id">
      <option value="" ng-model="category" 
              ng-change="filterCategory(category)">All</option>
           </select>   

和控制器:

$scope.filterCategory = function (cat) {
    cat = cat === null ? 'all' : cat
    $('#sandbox').mixItUp('filter', cat);
};

这就是正常工作的JSFiddle: http://jsfiddle.net/dp31o591/3/