axel-zarate / js-custom-select

Custom auto-complete select box for AngularJS and Bootstrap
MIT License
68 stars 59 forks source link

Changed options are not reflected when the search has value #15

Open SamiSammour opened 9 years ago

SamiSammour commented 9 years ago

Hello, nice work you did here thanx a lot, but I have this problem that can be found also in the example you provided with the package, in the last Nested example if you chose one option from the first select then opened the second select and typed some thing in the search box and then if you chose another option from the first select then opened the menu from the second select then the filtered array is still the previous one and it can be selected.

axel-zarate commented 8 years ago

I just added an experimental feature cs-depends-on to specify dependence on another model value, in case of cascading dropdowns. Let me know if it works.

alakh-shankar commented 6 years ago

Hello How can use "cs-depends-on" On cascading drop-down. I try to use but not working. Please explain.

alakh-shankar commented 6 years ago

Hello How can use "cs-depends-on" On cascading drop-down. I try to use but not working. Please explain.

Hello i have solve this issue Set on target control cs-depends-on="{'State':State }"
Also you can set from cascading control for update ng-change="City=''" in Html Here "State" And "City" is ng-model I have worked on this type of json [{"Country":"India","State":"New Delhi","City":"Delhi"},{"Country":"India","State":"Haryana","City":"Gurugram"},{"Country":"India","State":"Haryana","City":"Ambala"},{"Country":"India","State":"Madhya Pradesh","City":"Indore"},{"Country":"India","State":"Madhya Pradesh","City":"Bhopal"},{"Country":"India","State":"Maharashtra","City":"Mumbai"},{"Country":"India","State":"Maharashtra","City":"Pune"},{"Country":"India","State":"Maharashtra","City":"Aurangabad"},{"Country":"India","State":"Uttar Pradesh","City":"Noida"},{"Country":"India","State":"Uttar Pradesh","City":"Agra"},{"Country":"India","State":"Uttar Pradesh","City":"Allahabad"},{"Country":"India","State":"Uttar Pradesh","City":"Banaras"},{"Country":"India","State":"Tamilnadu","City":"Chennai"},{"Country":"India","State":"Gujarat","City":"Ahmedabad"},{"Country":"India","State":"Gujarat","City":"Ankaleshwar"},{"Country":"India","State":"Gujarat","City":"Vadodara"}]

Update js-custom-select.js with Below code

function filterParams(arr, params) { var new_array = arr.filter(function (item) { var select = 1 angular.forEach(params, function (val, key) { select = params[key] === item[key]; }) return select; }); return new_array; } if (dependsOn) { scope.$watch(dependsOn, function (newVal, oldVal) { if (newVal !== oldVal) { var m = values.match(VALUES_REGEXP); if (m) { var originalValues = m[0]; scope.$watchCollection(originalValues, function (values) { if (angular.isArray(values)) { var res = filterParams(values, newVal); childScope.matches = res; } }, function () { resetMatches(); }); } } }); }