Material Angular md-autocomplete clear and blur after selection (multi select) -
i trying use md-autocomplete in angular material multi selector. idea is, selected element autocomplete added object array after selection , selection removed md-autocomplete. able clear md-autocomplete, focus stays on md-autocomplete input , autocomplete suggestions still visible. example: http://cdpn.io/qjqgvq
code:
function selecteditemchange(item) { $log.info('item changed ' + json.stringify(item)); if(item) { //check if item selected if($filter('filter')(vm.contactsselected, function (d) {return d.id === item.id;})[0]) { $log.info('item selected. not add again.'); } else { //add id object vm.contactsselected.push(item); } // clear search field vm.searchtext = ''; vm.selecteditem = undefined; //somehow blur autocomplete focus //$mdautocompletectrl.blur(); } }
ps: aware use contact chips of angular material instead, still wondering how blur achieved.
if set md-no-cache="true" property inside list dissapear, input field not cleared. think better solution clearing input field leaving list visible, you.
Comments
Post a Comment