【发布时间】:2018-04-15 18:33:42
【问题描述】:
<html>
<body>
<div ng-app="mvcapp" ng-controller="AngularController">
<input ng-keyup="obj.showList = true;" type="text" class="myInput form-control" name="txtStorename" id="txtStorename" placeholder="Search for Store.." title="Type in a Store" data-error-message="Please enter StoreName" ng-model="sname">
<ul ng-if="obj.showList" id="myUL" ng-repeat="StoreList in Store| filter:{StoreName:sname}">
<li ng-click="SelectedValue(StoreList.StoreName)" ng-cloak>{{StoreList.StoreName}}</li>
</ul>
<div ng-show="(Store|filter:sname).length==0" style="color:red;font-weight:bold" ng-cloak>No Result Found</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js"></script>
<script>
var angular = angular.module('mvcapp', []);
angular.controller('AngularController', function ($scope, $http) {
$scope.obj = {};
$scope.obj.showList = false;
Getallitem()
function Getallitem() {
$http.get('/Coupons/GetStore').success(function (data) {
$scope.Store = data;
});
}
$scope.SelectedValue = function (item) {
$scope.sname = item;
$scope.obj.showList = false;
}
});
</script>
</body>
}
这是我在 Angularjs 中过滤列表的代码。这段代码一切都很好。我真正想要的是在列表中使用键盘,即箭头键并使用 enter 选择值。这样在过滤列表时我也可以使用键盘。
【问题讨论】:
-
@DudeSweet 你能帮我解决这个问题吗?
标签: javascript c# jquery asp.net angularjs