我尝试传递ID并通过web api调用获取相应的详细信息。我通过ng-grid cell-template传递了id,但我一直收到错误:
达到10 $ digest()次迭代。中止! 观察者在最近5次迭代中被解雇:[]
此后,屏幕变得无法响应。 我在这里查看了这个链接:https://github.com/angular-ui/ui-grid/issues/3753,但没有帮助。我只有4条记录必须被提取,但它会进入一个无限循环!
以下是我的代码: -
我的控制器的一部分: -
$scope.callContactService = function (creatorId) {
var CreatorName = "";
strFactory.getById(creatorId).then(function (currentUser) {
CreatorName = currentUser.Result.FirstName + " " + currentUser.Result.LastName;
$scope.operationTasks.CreatorName = CreatorName;
});
return $scope.operationTasks.CreatorName;
};
$scope.gridViewMyTasks = {
enablePaginationControls: false,
enableGridMenu: true,
paginationPageSize: pagingConfig.pageSizes[0],
enableHorizontalScrollbar: uiGridConstants.scrollbars.NEVER,
columnDefs: [
{
name: 'CreatorName',
displayName: 'Creator Name',
cellTemplate: "<div class='ui-grid-cell-contents'>{{grid.appScope.callContactService(row.entity.CreatorName)}}</div>",
enableColumnMenu: true,
visible: true
}]}
调用web api方法: -
getById: function (userId) {
config = {
params: {
userId: userId
}
};
var deferred = $q.defer();
$http.get(api/details/getById ,config)
.success(function (data) {
deferred.resolve(data);
}).error(function (response) {
if (response.Message){
sharedScopeStorage.store('errorMessage', response.Message);
}
else{
sharedScopeStorage.store('errorMessage', userNotificationConfig.get_user_error_message);
}
deferred.reject(response);
});
return deferred.promise;
}
任何帮助都会受到赞赏,自从几天以来我一直坚持这一点!