I have a problem with a filter in AngularJS. See my code here: http://jsfiddle.net/sqev9/7/
I have a select that uses a filter in the ng-options field:
ng-options="listitem as listitem.Name for listitem in MyList.Items|filter:FilterList"
I also use an empty option because this select is optional.
As ng-model for the select I use the value "SelectedInList"
The problem is now that when the filter doesn't match anything, the "SelectedInList" variable in my $scope is not null then.
Simulate this by selecting "item1" and pressing "Go": the SelectedInList is now correctly the item1 object. Now the filter changes and the list is "empty": only the "-" item is there, which is also expected. Now pressing "go" again should give me "null" as SelectedInList, but it is still the item1 object, which I don't expect.
Any solutions to this approach?
Best regards, Tom,
Seems that when the list is filtered and the value is no more, there is no update on the ng-model. This seems pretty much like a bug, but I would need more research to understand the reason.
Anyway, a solution is to set SelectedInList to null at the end of Add method.