【发布时间】:2015-07-02 22:51:59
【问题描述】:
我有四个服务调用函数用于屏幕中的下拉绑定,我正在使用angularjs http 调用从WEB API 服务获取数据。
以下是方法
function loadProjects() {
$http({
method: 'GET',
url: rootUrl + '/api/Project/ProjectList',
headers: {
'Content-Type': "application/json; charset=utf-8"
}
}).success(function (response) {
response.push({ ProjectName: "Select", ProjectId: 0 });
$scope.ProjectList = response;
$scope.SelectedProject = response[$scope.ProjectList.length - 1];
}).error(function (response, errorCode) {
if (errorCode == 444) {
//toastr.error('Your email address is does not verrified ', 'Error');
}
})
}
function loadTasks() {
$http({
method: 'GET',
url: rootUrl + '/api/Task/TaskList',
headers: {
'Content-Type': "application/json; charset=utf-8"
}
}).success(function (response) {
$scope.TaskList = response;
}).error(function (response, errorCode) {
if (errorCode == 444) {
//toastr.error('Your email address is does not verrified ', 'Error');
}
})
}
function loadStatus() {
$http({
method: 'GET',
url: rootUrl + '/api/Status/GetAllStatus',
headers: {
'Content-Type': "application/json; charset=utf-8"
}
}).success(function (response) {
response.push({ StatusTypeName: "Select", StatusTypeId: 0 });
$scope.StatusType = response;
$scope.SelectedStatusType = response[$scope.StatusType.length - 1];
}).error(function (response, errorCode) {
if (errorCode == 444) {
//toastr.error('Your email address is does not verrified ', 'Error');
}
})
}
function loadUserList() {
$http({
method: 'GET',
url: rootUrl + '/api/Account/ListOfUsers',
headers: {
'Content-Type': "application/json; charset=utf-8"
}
}).success(function (response) {
response.push({ FirstName: "Select", UserId: 0 });
$scope.UserList = response;
$scope.SelectedUser = response[$scope.UserList.length - 1];
}).error(function (response, errorCode) {
if (errorCode == 444) {
//toastr.error('Your email address is does not verrified ', 'Error');
}
})
}
上面的函数我已经一一调用了。
loadUserList();
loadProjects();
loadStatus();
loadTasks();
HTML : I have binding the four dropdown by this way
<select style="width: 160px" ng-model="SelectedTask" class="form-control" name="SelectedTask"
ng-options="tasklist.TaskName for tasklist in TaskList">
</select>
前两个函数从WEBAPI 获取一些数据非常慢,我的数据库只有 5 行。但很慢。但我在另一个屏幕上使用相同的功能,效果很好。
每当loadStatus(); (第三个函数) 函数调用时,我都会收到此错误消息。
错误消息是:JavaScript 运行时错误:没有足够的存储空间来完成此操作。在 angularjs 中
当我运行其他一些屏幕与检测到问题的屏幕时,我还将显示性能详细信息。
查看CPU 的用法。我找不到解决方案。请帮帮我。
我也从谷歌得到了一些答案,但他们说这是一个视觉工作室的问题。但我认为这不是问题。因为其他屏幕运行良好。请帮帮我;)提前谢谢
【问题讨论】:
-
你的javascript错误只在IE中吗?
-
是的,我只在 IE 中遇到了这个错误。其他浏览器不显示任何错误。但我只遇到了性能问题。
-
嗯,k。您是否尝试过检查 ajax 调用中的响应?我只是想确认您没有拉入您不想要的东西。例如,一个 ORM 可能会意外地拉入连接的表,最终您会得到一个巨大的模型对象,而不是您期望的一小行。
-
另外,您是否尝试过使 ajax 调用同步(不理想,但用于调试)。将下一个调用放入每个调用的成功回调中,看看它是否因为所有 ajax 调用都立即返回而受到猛烈抨击。它应该能够处理这个......不过还有更多......只是一个想法。
标签: javascript html angularjs performance asp.net-web-api