We have two angularjs services. The first service is called initially to retrieve data, then the second service is called. When adding a breakpoint on 'self' in the second service, its always populated with 'self' from the first service. ie contains 'isloadinggrid etc'. Is there a reason for this? i had assumed that self in each would have been unique to the service object.
(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,
};
}]);
})();