我正在使用Ionic Framework开发我的应用程序,我将Firebase作为后端。我把断点和尝试运行它运行良好的应用程序。但是,如果我在没有调试器的情况下运行应用程序,我会看到Firebase数据库中的值未被更改,并且页面转换也会失败。任何可能的原因,它以这种方式行事。
我的部分内容:
$sql = "$db_name.$db_table $where $where_search $db_sort";
$result = mysqli_query ($conn, "select * from $sql $limit");
$rec = mysqli_fetch_array(mysqli_query($conn, "SELECT COUNT(*) as totalCount FROM $sql"));
$db_count = $rec['totalCount'];
我的Controller.js文件的一部分
<a class="button button-balanced button-block" id="snooker-button1" ng-click = "setTitle('Table 1')" ui-sref="tableX">Table 1</a>
<a class="button button-balanced button-block" id="snooker-button2" ng-click = "setTitle('Table 2')" ui-sref="tableX">Table 2</a>
<a class="button button-balanced button-block" id="snooker-button3" ng-click = "setTitle('Table 3')" ui-sref="tableX">Table 3</a>
<a class="button button-balanced button-block" id="snooker-button4" ng-click = "setTitle('Table 4')" ui-sref="tableX">Table 4</a>
<a class="button button-assertive button-block" id="snooker-button5" ng-click = "setTitle('Table 5')" ui-sref="tableX">Table 5</a>
<a class="button button-balanced button-block" id="snooker-button6" ng-click = "setTitle('Table 6')" ui-sref="tableX">Table 6</a>
<!-- <div style="" class="button-bar"></div> -->
<div style="" class="button-bar">
<button class="button button-calm button-block button-outline" style="font-weight:600;" id="page3-button11" ng-click = "gameEngine_v()" >Start</button>
<button class="button button-calm button-block button-outline" style="font-weight:600;" id="page3-button12"ng-click = "gameEngine_v_stp()" >Stop</button>
})
答案 0 :(得分:2)
正如大卫已经评论过的那样,这通常是由于竞争条件造成的。如果你的JS虽然因为Async调用没有正确处理。 Firebase dbref.on
是异步调用。当从服务器接收数据时,该函数将执行。所以处理tables_snapshot
&amp; players_at_table_snapshot
必须位于各自的异步处理程序函数中。你把它放在外面导致问题。