【问题标题】:how to hide list when user select item from list?当用户从列表中选择项目时如何隐藏列表?
【发布时间】:2015-04-23 12:32:51
【问题描述】:

您能否告诉我当用户从列表中选择项目时如何隐藏列表。实际上,当用户在文本字段中键入任何内容时,它会显示一个列表,当用户从列表中选择任何行时,它会在文本字段上设置值。但是那个时候我需要隐藏我的列表。所以我使用一个布尔变量 $scope.islisthide=false; 使用我需要隐藏或显示列表的值。请按 "a"比从列表中选择值。我已经使用 ng-show 但如何在其中添加条件。

<div class="listcontainer" ng-show="SEARCH.stationCode" >
    <li ng-click="rowclick(station)" class="item" ng-repeat="station in data.data | filter:SEARCH.stationCode :startsWith">{{station.stationName+"-("+station.stationCode+")"}}</li>
</div> 

$scope.rowclick = function(station) {
    $scope.SEARCH.stationCode=station.stationCode;
    //  $scope.$apply();
}

这是我的代码 http://codepen.io/anon/pen/zGYPWj

【问题讨论】:

    标签: javascript angularjs angularjs-directive angularjs-scope


    【解决方案1】:

    只需使用一个标志来指示是否进行了选择。这是一个例子:

    http://codepen.io/anon/pen/RPwjvN

    我正在使用一个名为selected的标志

    【讨论】:

      猜你喜欢
      • 2013-06-28
      • 2023-03-29
      • 2013-07-13
      • 2016-12-23
      • 2014-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-19
      相关资源
      最近更新 更多