因此,使用Angular.js控制器从数据库中获取结果集,数据是无关紧要的。当结果返回false(没有找到行)时,正确的div显示“empty!”。ng显示工程,但快速显示两个div
当结果恢复正确时,div为空!显示一秒钟,然后“结果!”显示。这种行为让我想起了jQuery .hide()
,我把我的代码放在下面,但我仍然无法弄清楚为什么会发生这种行为?
HTML:
<h1 class="page-header">
Products
<small>
<i class="fa fa-angle-double-right text-primary"></i> add
</small>
</h1>
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">
<div ng-show="categoriesFound">results!</div>
<div ng-show="!categoriesFound">empty!</div>
</div>
</div>
角控制器:
mbpApp.controller('ProductsCtrl', function(httpService, $scope) {
httpService.productCategoriesFindAll().then(function(d) {
$scope.data = d;
if(d.status) {
$scope.categoriesFound = true;
} else {
$scope.categoriesFound = false;
}
});
});
我猜你正在使用Twitter Bootstrap的'.row'和'.col-'标记。你只需要'.col-sm-12',另外两个是多余的。 – 2014-09-05 04:23:23
你是对的。老习惯很难死我猜..... – Naterade 2014-09-05 04:42:08