我有一个角度控制器和一个视图。控制器代码如下:
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>
我遇到的问题是有些用户看不到启动调查的按钮。
答案 0 :(得分:1)
验证他们没有获得200以外的响应,或者这些客户端的$ scope.totalAnsweredQuestions为0。如果你在if($ scope.totalAnsweredQuestions&gt; 0)内部调试console.log并且他们仍然没有看到按钮,那么尝试识别他们的客户端硬件的差异(较慢的机器,可能是服务响应的竞争条件)和客户端渲染页面)或客户端浏览器的差异(他们使用浏览器X,你使用Y)