我们有两个angularjs服务。首先调用第一个服务以检索数据,然后调用第二个服务。在第二个服务的“自我”上添加断点时,它总是由第一个服务的“自我”填充。即包含“ isloadinggrid等”。是否有一个原因?我以为每个对象中的self对于服务对象都是唯一的。
(function () {
'use strict';
angular.module('IPortal.Angular.Components.List.Shared.List.Factory', [])
.service('listfactory', ['$http', 'loggingService', 'listApiLink', 'listFormRenderService', 'listGridRenderService', function ($http, loggingService, listApiLink, listFormRenderService, listGridRenderService) {
self.Model = {
IsLoadingGrid: false,
IsLoadingForm: false,
TotalColumns: 0,
TotalRows: 0,
List:[],
ListGrid: [],
ListForm: [],
ListFormTemplateURL: '',
ListGridTemplateURL: '',
BaseDate: new Date(),
PendingUpdates : [],
};
return {
GetListbyId: function (id, listType) {
self.GetListbyId(id, listType);
return self.Model;
},
GetListDetailbyId: function (id, listType) {
self.GetListDetailbyId(id, listType);
return self.Model;
},
SaveAnswer: function (pendingQuestion) {
var pendingAdd = true;
if (self.Model.PendingUpdates.length > 0) {
self.Model.PendingUpdates = self.Model.PendingUpdates.filter(function (pendingValue) {
if (pendingValue.id === pendingQuestion.id) {
pendingAdd = true
return false
}
return true;
});
}
if (pendingAdd) {
self.Model.PendingUpdates.push(pendingQuestion)
}
},
Save: function () {
var y = self.Model.PendingUpdates;
}
};
}]);
})();
2。
(function () {
'use strict';
angular.module('IPortal.Angular.Components.List.ListForm.InputDirectives.ClinicalOrderStatus.factory', [])
.service('clinicalorderstatusfactory', ['$http', 'loggingService', function ($http, loggingService) {
self.Model = {
primaryKey: 0,
status : '',
statusCode : '',
};
self.UpdataStatus = function (primaryKey, patientId, status, reason, accountId) {
};
self.RenderForm = function () {
self.Model.ListFormTemplateURL = listFormRenderService.Render(self.Model.ListForm);
self.Model.FormTemplateIsRendered = true;
}
return {
UpdateStatus: function (primaryKey, patientId, status, reason, accountId) {
self.UpdataStatus(primaryKey, patientId, status, reason, accountId);
return self.Model;
},
Data: self.Model,
};
}]);
})();