我具有搜索数据库的功能
app.limit = 5; // Set a default limit to ng-repeat
app.searchLimit = 0; // Set the default search page results limit to zero
app.search = function(searchKeyword, number) {
// Check if a search keyword was provided
if (searchKeyword) {
// Check if the search keyword actually exists
if (searchKeyword.length > 0) {
app.limit = 0; // Reset the limit number while processing
$scope.searchFilter = searchKeyword; // Set the search filter to the word provided by the user
app.limit = number; // Set the number displayed to the number entered by the user
} else {
$scope.searchFilter = undefined; // Remove any keywords from filter
app.limit = 0; // Reset search limit
}
} else {
$scope.searchFilter = undefined; // Reset search limit
app.limit = 0; // Set search limit to zero
}
};
以及使用搜索功能的输入。每次用户按下一个键,表格都会过滤
<input type="text" class="form-control" name="search"
placeholder="search for..."
ng-model="searchKeyword"
ng-keyup="management.search(searchKeyword, number);">
问题是当我退格所有字符串并且没有输入,表格没有显示数据时,是否有任何方法可以检测输入是否为0,所以我可以使用函数management.showAll();
函数
// Function: Show all results on page
app.showAll = function() {
app.limit = undefined; // Clear ng-repeat limit
app.showMoreError = false; // Clear error message
};
答案 0 :(得分:0)
<script src="//unpkg.com/angular/angular.js"></script>
<body ng-app ng-init="value='0'">
<input type="text" ng-model="value" />value={{value}}<br>
<div ng-show="value=='0'">
Input is "0"
</div>
</body>