I have a list(master) of element which contains also a list(child) of elements. what I want is : If I choose an element from the first list(master) I get a list of checkbox alimented with the appropriated element from the list child
My problem is that when I check an element for example "1" the first element in child list for the first element in master list, and I return to choose the second element I found that the first element in the child list (for the second element in the master list) is also checked. how can I manage this knowing that I feed my child list with a factory and this is my factory:
app.factory("Fctr", ["Restangular", function(Restangular) {
var currentObj = {};
currentObj.testz = function(myObj){
var selectedVersion = [];
var masterElements = [];
var params = {
query: {
"id": myObj.id
}
};
var service = Restangular.all('mycollection');
selectedVersion = service.getList(params).then(function(response) {
var selectedVersions = response[0].refVersions;
for (var k in selectedVersions) {
if (selectedVersions[k].vCode == myObj.vCode) {
masterElements = selectedVersions[k].masterElements;
}
}
currentObj.masterElements = masterElements;
});
};
return currentObj;
}]);
in the controller I'm using factory with this function:
$scope.beginPreparation = function(myObj){
$scope.Fctr.testz(myObj);
};
Aucun commentaire:
Enregistrer un commentaire