Sorry to ask this question again but no answer or workaround has been identified.
This is a follow-up of this question : Stackoverflow
I have a plunker which describes the issue (basically putting a tree structure in a dropdown list) :
As illustrated the first select does not select the value and gets back to an empty line - which is also a mystery.
I have not been able to find any similar cases and I am close to giving up so this is the last chance.
Key code areas are the filter and the initTreeSelect function :
$scope.initTreeSelect = function(tree){
$scope.filteredFields = $filter('flattenTree')(tree);
return $scope.filteredFields[0];
};
angular.module('myApp.filters', []).filter('flattenTree', function (OrgSvc) {
return function (array) {
var arrayToReturn = [];
arrayToReturn = OrgSvc.flattenTree(array);
return arrayToReturn;
};})
Your help would be very much appreciated! Thanks
What Dayan Moreno Leon wrote in his answer is actually correct. And the problem really is that angular keeps losing track of the model data (because by default objects/arrays are identified by reference).
This is thwarted, because your
flattenTree
keeps returning newly created objects:For your concrete problem though, I think using
track by
will help, e.g.:demo: http://plnkr.co/edit/J8PyypC61uzx8PPNV6Zu?p=preview