【发布时间】:2015-08-06 22:00:17
【问题描述】:
在 Cordova 应用程序中,我一直在尝试像这样绑定角度标记:
<table class="table table-striped table-responsive">
<thead>
<tr>
<th>Rotation</th>
<th>ID</th>
<th>Name</th>
<th>DOB</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in dtPatients track by item.fldRotation">
<td>{{item.fldRotation}}</td>
<td>{{item.fldID}}</td>
<td>{{item.fldTitle + " " + item.fldForename + " " + item.fldSurname}}</td>
<td>{{item.fldDOB | date:'dd/MMM-yy'}}</td>
</tr>
</tbody>
</table>
像这样在控制器中进行简单的 WebSQL 事务:
tx.executeSql("Select * from [tblPatients];"
, []
, function (tx, results) {
if (results.rows.length == 0) {
$scope.dtPatients = null;
$scope.$apply();
}
else {
// We have records so we create an array of the results
$scope.dtPatients = results.rows;
$scope.$apply();
debugger;
}
}
, function (tx, err) {
console_log("Error retrieving patients.");
$scope.dtPatients = null;
logdberror(err.code, err.message);
errorsource = -1;
ShowError('PatientsController1 load patients', err.code.toString + " " + err.message);
$scope.$apply();
}
);
这会产生一个错误,唯一的解决方法是使用here 所示的代码将行转换为数组。我注意到作者在链接中提到的错误,但我不确定这是我得到的错误。我还尝试将 ng-repeat 从上面显示的内容更改回我从一开始就拥有的内容
ng-repeat="item in dtPatients"
无论哪种方式,我都会不断收到相同的错误。绑定之前确定不需要将 SQL 结果集转换为数组吗?
这是给出的错误:
达到 10 次 $digest() 迭代。中止!观察者在最后被解雇 5 次迭代: [[{"msg":"fn: function (c,d){var e=a(c,d);return b(e,c,d)}","newVal":17,"oldVal":15}],[{"msg":"fn: 函数 (c,d){var e=a(c,d);返回 b(e,c,d)}","newVal":19,"oldVal":17}],[{"msg":"fn: 函数 (c,d){var e=a(c,d);返回 b(e,c,d)}","newVal":21,"oldVal":19}],[{"msg":"fn: 函数 (c,d){var e=a(c,d);返回 b(e,c,d)}","newVal":23,"oldVal":21}],[{"msg":"fn: 函数 (c,d){var e=a(c,d);返回 b(e,c,d)}","newVal":25,"oldVal":23}]] at Error (native) at localhost:4400/scripts/angular.min.js:6:417 在 n.$get.n.$digest (localhost:4400/scripts/angular.min.js:124:185) 在 n.$get.n.$apply (localhost:4400/scripts/angular.min.js:126:293)
提前感谢您的任何帮助/建议。
【问题讨论】:
-
也许这会帮助你理解你的错误railsguides.net/…
标签: javascript angularjs sqlite cordova web-sql