2015-04-01 35 views
0

我将使用以前使用的jsfillde选择值,然后只调用函数

正如您在点击过滤器(汤,肉等)时看到的那样,过滤结果载入实时。我想,而不是让用户进行选择和然后触发由cliking一个“更新”按钮的结果(以enhcance移动性能)

我相当不确定如何在JavaScript中达致这,我非常新。我使用离子,下面是HTML片段来调用过滤功能。

<ion-item ng-repeat="dish in dishList | selectedDishType:selection "> 
     <article class="item_frame"> 
       <h1 class="item_name_english">{{dish.nameEnglish}}</h1> 

       <h2 class="item_name_local_language">{{dish.nameLocal}}</h2> 

      <p class="item_description ">{{dish.description}}</p> 
     </article> 
     <!--main article frame 1 --> 
    </ion-item> 

回答

1

添加一个按钮:

<div class="listing_venue_types_filter_page"> 
     <div class="input_dishtype_selection " data-ng-repeat="dishType in dishTypeList" ng-class="{'filter_selected':selection.indexOf($index) != -1}" ng-click="toggle($index)">{{dishType.name}}</div> 
    </div> 
    <button class="button" ng-click="updateDisplay()">Update</button> 

,并在控制器: 信号发送的动作移动到一个新的作用域功能

$scope.updateDisplay = function() { 
    //calling an event to any listener with the latest selection data. 
     $rootScope.$emit('dishType.selectionChanged', $scope.dishTypeList.filter(function (dType, idx) { 
      return $scope.selection.indexOf(idx) != -1; 
     }).map(function (dType) { 
      return dType.name.toLowerCase(); 
     })); 
     //calling an event to any listener with the latest selection data. 
    }; 
+0

谢谢!在jsfiddle上精美地工作,现在试图在本地执行... – lauWM 2015-04-01 16:42:26

+0

我无法使其在本地工作...不知道发生了什么问题... – lauWM 2015-04-01 17:48:12

+0

什么问题出在哪里? – Calden 2015-04-02 08:25:06

相关问题