在自定义指令angularjs中传递筛选列表

时间:2017-09-14 07:46:20

标签: angularjs ionic-framework angularjs-directive

我有一个名为eventPlans的对象列表,在带有一些过滤器的div中显示。现在我想将名为pendingEventPlans的筛选列表传递给我的搜索指令中的另一个指令。

<div> 
    <search-box list-to-count="pendingEventPlans" search-text="searchText" display-text="'Total event plans'"></search-box>
       <div class="has-search-with-count">
          <div class="list card" ng-repeat="item in pendingEventPlans = (eventPlans | orderBy : 'from_date'| filter:pendingFilter | filter:searchText )">
               <div>{{item.name}}</div>
           </div>
       </div>
</div>

然后在search-box指令中,列表未定义。

实际问题出在我的ionic v1应用代码中。我构建了一个fiddle来尝试模拟问题。

1 个答案:

答案 0 :(得分:0)

此时pendingEventPlans未定义,您应该执行以下操作:

<div> 
<search-box list-to-count="(eventPlans | filter:pendingFilter | filter:searchText )" search-text="searchText" display-text="'Total event plans'"></search-box>
   <div class="has-search-with-count">
      <div class="list card" ng-repeat="item in pendingEventPlans = (eventPlans | orderBy : 'from_date'| filter:pendingFilter | filter:searchText )">
           <div>{{item.name}}</div>
       </div>
   </div>