这是我的代码。如果loadTags返回空结果,那么有没有办法显示没有找到结果的消息?
var ysBackButton:UIButton = UIButton(frame:CGRectMake(0, 0, kNavBtnSize, kNavBtnSize))
ysBackButton.setImage(UIImage(named: kBack), forState: UIControlState.Normal)
ysBackButton.addTarget(self, action: Selector("backButtonAction"), forControlEvents:UIControlEvents.TouchUpInside)
var leftBarButton:UIBarButtonItem = UIBarButtonItem(customView: ysBackButton)
self.navigationItem.leftBarButtonItem = leftBarButton
答案 0 :(得分:-2)
我不知道你在使用ng-show在ng-repeat中使用的api / data(数组)是什么显示在html中显示“找不到结果”标签这里是代码
function MyCtrl($scope, $filter)
{ $scope.nodata = false;
$scope.items = [
{id:1, name:'John'},
{id:2, name:'Steve'},
{id:3, name:'Joey'},
{id:4, name:'Mary'},
{id:5, name:'Marylin'}];
$scope.items2 = $scope.items;
$scope.$watch('search', function(val)
{
console.log($filter('filter')($scope.items2, val));
$scope.items = $filter('filter')($scope.items2, val); // items return for api after search if array is empty
if($filter('filter')($scope.items2, val).length == 0){ // item are empty
$scope.nodata = true;
}
else{
$scope.nodata = false;
}
});
};
HTML
<div ng-app>
<div ng-controller="MyCtrl">
<input type="text" ng-model="search">
<table>
<tbody>
<div ng-show="nodata">NO results found</div>
<tr ng-repeat="item in items">
<td>{{item.id}}</td>
<td>{{item.name}}</td>
</tr>
</tbody>
</table>
</div>
</div>
CSS代码
.no_rocord{border-color: #ececec;
border-width: 1px;
border-style: solid;
border-radius: 2px;
width: 250px;
padding: 6px;
cursor: pointer;
z-index: 9999;
position: absolute;
margin-top: -6px;
background-color: #ffffff
}