【发布时间】:2016-12-10 03:18:33
【问题描述】:
我正在使用$ionicLoading 加载新闻页面,如果没有找到新闻,那么这将在我的模板上运行:<div ng-show="!news.length" class="empty"> Nothing to show ! </div>
问题:加载时会显示空 div(Nothing to show !),所以如果有消息,那么该 div 将隐藏。现在如果没有找到文章,我需要在加载完成后显示该消息。
我的控制者:
.controller('detailsCtrl', function ($scope, $ionicHistory, $stateParams, $http, $ionicLoading, $ionicFilterBar, $rootScope) {
$scope.init = function () {
var id = $stateParams.id;
$ionicLoading.show({
template: '<ion-spinner icon = "ripple" class="spinner-light"></ion-spinner>',
duration: 20000
});
$http.get('http://localhost/json/article_details.php?id=' + id).then(function (output) {
$ionicLoading.hide();
$scope.news = output.data;
console.log(angular.toJson(output.data));
});
};
});
我的 HTML 模板:
<ion-view ng-init="init()">
<!-- If news not found -->
<div ng-show="!news.length" class="empty"> Nothing to show ! </div>
<!-- If news found -->
<div ng-repeat="news in news">
...
【问题讨论】:
标签: angularjs ionic-framework loading ng-repeat ng-show