ng-select无法在离子弹出框中重置为默认值

时间:2015-12-17 20:46:31

标签: angularjs ionic-framework ionic

我有一个按预期工作的ng-select,减去了当我执行一个函数来更新其ng-model时,它会更新各种其他过滤器以及依赖于该值的东西,但它并没有。实际上重置了html选项。

当您选择离子选项卡时,它会运行函数resetFilters(),如以下html片段所示:

...
<ion-tab on-select="resetFilters('required')" title="Required" icon-on="ion-university" icon-off="ion-university">
...

选择值&#34; Descending&#34;在下拉菜单中,然后单击一个选项卡,它运行resetFilters()函数就好了,但它没有将它重置回&#34; Ascending&#34;,它只是停留在&# 34;降序&#34;

这是ng-select的html:

<ion-popover-view>
  <ion-content>
    <ul class="list search-filter-list">
      <li class="item">
        <label class="item item-input item-select">
          <div class="input-label">
            Sort
          </div>
          <select id="sort-direction" ng-model="sortDirectionItem"
                  ng-options="sort as sort.direction for sort in filterTitleItems.sort"
                  ng-change="filterByTitleDirection(sortDirectionItem)">
          </select>
        </label>
      </li>
    </ul>
  <ion-content>
<ion-popover-view>

以下是影响此问题的JavaScript:

$scope.resetFilters = function(tab) {
      $scope.selectedTab = tab;
      $scope.nameFilter = 'name';
      $scope.enrollmentFilterStatus = 'all';
      $scope.completionFilterStatus = 'all';
      $scope.sortDirectionItem = $scope.filterTitleItems.sort[0];
    }


    /* =================================
       Filter: By title - ascending/descending
       ================================= */
    $scope.filterTitleItems = {sort: [
        {
          direction: "Ascending",
        },
        {
          direction: "Descending",
        }
      ]
    }

    // Initialize the filter
    $scope.nameFilter = 'name';
    $scope.sortDirectionItem = $scope.filterTitleItems.sort[0];

    $scope.filterByTitleDirection = function(item) {

      if(item.direction == 'Ascending') {
        $scope.nameFilter = 'name';
      } else {
        $scope.nameFilter = '-name';
      }
    }

对我在这里失踪的想法有什么想法?

0 个答案:

没有答案