function detailCtrl($scope, $state, $stateParams, documentService, $q) {
var self = this;
self.detailedDocObj = null;
init();
function init() {
self.docId = $stateParams.documentId;
getFiledetails();
}
function getFiledetails() {
documentService.getDetailedDocument(self.docId, getDocumentSuccess, failure);
}
function getDocumentSuccess(detailedDocObj) {
if (detailedDocObj) {
self.detailedDocObj = detailedDocObj;
}
}
}
我有一个控制器,我在其中通过调用服务加载一些数据,并在成功回调时使用这些数据在 UI 上呈现它。
下面是服务代码
function getDetailedDocument(docId, callback, errback) {
var url = "Document/Get?fileId=" + docId;
httpWrapperService.get(url).then(
function success(data) {
callback(srvToJsDoc(data));
},
function error(errorObject) {
errback(error);
}
);
}
function srvToJsDoc(srvDoc) {
if (srvDoc) {
var jsDoc = {
creationDate: srvDoc.CreationDate
}
//Problem in array
var documentVersions = [];
for (var index in srvDoc.DocumentVersions) {
var doc = srvDoc.DocumentVersions[index];
documentVersions.push(
{
id: doc.Id,
name: doc.Name,
label: doc.Label,
userName: doc.Username,
creationDate: doc.CreationDate
});
}
jsDoc.documentVersions = documentVersions;
return jsDoc;
}
else {
return null;
}
}
现在您可以在 srvDoc 函数中看到我正在创建一个新数组并存储 srvDoc.DocumentVersions 数组中的值。
成功回调在我的控制器内部,我得到了object detailedDocObj
正确的结果。但是在我的控制台上我得到了错误
Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [[{"msg":"fn: function (){return o(a)}","newVal":[],"oldVal":[]}],[{"msg":"fn: function (){return o(a)}","newVal":[],"oldVal":"<<already seen>>"}],[{"msg":"fn: function (){return o(a)}","newVal":[],"oldVal":"<<already seen>>"}],[{"msg":"fn: function (){return o(a)}","newVal":[],"oldVal":"<<already seen>>"}],[{"msg":"fn: function (){return o(a)}","newVal":[],"oldVal":"<<already seen>>"}]]
我也浏览了其他一些帖子,但无法弄清楚,数组中发生的问题和位置。即使我正在设置,我也在页面加载时调试代码null value in self.detailedDocObj
,但我仍然能够查看DocumentVersion
它在服务调用期间保存的数组值。
我在做什么错误,无法找出。任何帮助表示赞赏谢谢!!!