在 AngularJS Material 中首次单击时显示自动完成下拉菜单
Show autocomplete dropdown at first click in AngularJS Material
我有一个来自 AngularJS Material 的 md-autocomplete 组件,它在第一次单击输入后没有显示带有选项的下拉列表,正如它应该显示的那样。当我完成搜索后单击输入然后删除输入的输入时,它会在下拉列表中显示完整的选项列表。谁能说出我的代码有什么问题?
这是我的代码:
我尝试了 md-min-legth 属性,但它不起作用。
<md-autocomplete ng-disabled="false"
md-no-cache="true"
name="projectAutocompleteFormRecord"
md-selected-item="model.TimeRecord.Project"
md-items="project in querySearchForProjectRecord(searchProjectTextRecord)"
md-item-text="project.Code + (project.DerivedCode ? project.DerivedCode : '') + '-' + project.Title"
md-search-text="searchProjectTextRecord"
md-min-length="0"
placeholder="Project">
<md-item-template>
<div class="item-title">
<span md-highlight-text="searchProjectTextRecord"
md-highlight-flags="ig">
{{project.Code + (project.DerivedCode ? project.DerivedCode : "") + "-" + project.Title}}
</span>
</div>
</md-item-template>
</md-autocomplete>
<script>
// initialize of $scope.projs;
$scope.searchProjectTextRecord = "";
$scope.querySearchForProjectRecord = function (query) {
var results = [];
var projects = $scope.projs;
if (projects) {
results = query ? projects.filter(item => item.Code.toLowerCase().includes(query.toLowerCase()) ||item.Title.toLowerCase().includes(query.toLowerCase())) : projects;
}
return results;
}
</script>
我设法通过添加 <md-not-found>
元素来修复它。
我有一个来自 AngularJS Material 的 md-autocomplete 组件,它在第一次单击输入后没有显示带有选项的下拉列表,正如它应该显示的那样。当我完成搜索后单击输入然后删除输入的输入时,它会在下拉列表中显示完整的选项列表。谁能说出我的代码有什么问题? 这是我的代码:
我尝试了 md-min-legth 属性,但它不起作用。
<md-autocomplete ng-disabled="false"
md-no-cache="true"
name="projectAutocompleteFormRecord"
md-selected-item="model.TimeRecord.Project"
md-items="project in querySearchForProjectRecord(searchProjectTextRecord)"
md-item-text="project.Code + (project.DerivedCode ? project.DerivedCode : '') + '-' + project.Title"
md-search-text="searchProjectTextRecord"
md-min-length="0"
placeholder="Project">
<md-item-template>
<div class="item-title">
<span md-highlight-text="searchProjectTextRecord"
md-highlight-flags="ig">
{{project.Code + (project.DerivedCode ? project.DerivedCode : "") + "-" + project.Title}}
</span>
</div>
</md-item-template>
</md-autocomplete>
<script>
// initialize of $scope.projs;
$scope.searchProjectTextRecord = "";
$scope.querySearchForProjectRecord = function (query) {
var results = [];
var projects = $scope.projs;
if (projects) {
results = query ? projects.filter(item => item.Code.toLowerCase().includes(query.toLowerCase()) ||item.Title.toLowerCase().includes(query.toLowerCase())) : projects;
}
return results;
}
</script>
我设法通过添加 <md-not-found>
元素来修复它。