That is my plunker: http://plnkr.co/edit/xTSsAVOQKErHOk0QYfWo?p=preview
What I do here is to bind a multiple selection option control to an array
of complex objects.
When I initialize the selectedItem/selectedSchoolclassCode this way:
$scope.activeStep.selectedSchoolclassCode = $scope.activeStep.
schoolclassCodes[0];
Then my selectedSchoolclassCode has all 3 properties inside.
But when I select a schoolclassCode in the multiple select list and press
the *delete *button:
$scope.activeStep.deleteSchoolclassCode = function () {
alert($scope.activeStep.selectedSchoolclassCode);
var index =
Enumerable.from($scope.activeStep.schoolclasses).indexOf(function (s) {
return s.schoolclassCode ===
$scope.activeStep.selectedSchoolclassCode.schoolclassCode;
});
$scope.activeStep.schoolclassCodes.splice(index, 1)[0];
$scope.activeStep.selectedSchoolclassCode = null;
};
then the selectedSchoolclassCode object has just a string instead of the
complex object literal.
The result is that the wrong object is deleted. Always the last element not
the selected one.
Why is the bound selectedSchoolclassCode in the wrong object structure?
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.