【发布时间】:2017-05-09 22:36:52
【问题描述】:
我有一个角度控制器和一个视图。控制器代码如下:
app.controller('someController',
['$scope', '$rootScope', '$location', '$routeParams', 'someService',
function ($scope, $rootScope, $location, $routeParams, someService) {
$scope.dataLoadingComplete = false;
$scope.hasStarted = true;
function getSurvey() {
$rootScope.loadingView = true;
someService.getSurvey().then(
function (results) {
$rootScope.loadingView = false;
$scope.dataLoadingComplete = true;
if (results.status === 200) {
//set other scope variables...
$scope.totalAnsweredQuestions = results.data.totalAnsweredQuestions;
if ($scope.totalAnsweredQuestions > 0)
$scope.hasStarted = true;
else
$scope.hasStarted = false;
}
},
function (error) {
//log error
$rootScope.loadingView = false;
$scope.dataLoadingComplete = true;
$scope.errorMessage = "Error occurred.";
});
}
getSurvey();
}]);
在视图中我有以下代码:
<div>
<p>Some content....</p>
<div ng-show="dataLoadingComplete">
<button ng-if="!hasStarted">Start Survey</button>
</div>
</div>
我遇到了一些问题,一些用户没有看到开始调查的按钮。
【问题讨论】:
-
'ng-if="!hasStarted"' 你能删除它并测试
-
我必须根据“已启动”条件显示不同的按钮
一些内容....
-
仅出于测试目的将其删除
-
我并不总是遇到按钮“开始调查”机器人显示的问题。我的应用程序的随机用户没有看到此按钮。所以,如果我删除测试条件,它总是对我有用。在没有任何问题之前我已经对此进行了测试。
-
任何控制台日志错误?