我有一个带有文本类型的输入框:
<input type="text></input>
我有一个名字列表:
$scope.employees = [{ name: "vishnu" }, { name: "seenu" }];
现在让它只有2。当我键入时v,它应该显示vishnu为建议。当我输入se, it should showseeu`作为建议时。如何做到这一点?
v
vishnu
se, it should show
的填充选项DataList控件与值$scope.employees与数据- NG-重复:
$scope.employees
var app = angular.module('myApp', []); app.controller('myController', function($scope, $http) { $scope.employees = [{ name: "vishnu" }, { name: "seenu" }]; }); <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="myApp" ng-controller="myController"> <input type="text" list="names" placeholder="Pick a name.."> <datalist id="names"> <option data-ng-repeat="item in employees" value="{{item.name}}"> </datalist> </div>
祝好运!