Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angucomplete-alt: getting value of text when it doesn't match

Angucomplete-alt works great for me when trying to force the user into a pre-defined selection among objects.

But if I don't want to force the user to one of those objects, if instead I want the user to be able to enter free text and only have the completions as suggestions, how then do I access the text of the input field?

For example I have a hidden field that marshals the string value of the Angucomplete-alt field for submission to the backend DB. Like this:

<input type="hidden" name="dance[start_type]"
       ng-value="IS_THERE_A_SELECTION ? selectedStartType.originalObject.name : JUST_TELL_ME_THE_STRING_THEY_TYPED"/> 

What expressions should I put for IS_THERE_A_SELECTION and JUST_TELL_ME_THE_STRING_THEY_TYPED?

like image 735
Dave Morse Avatar asked Jan 07 '23 16:01

Dave Morse


1 Answers

Been banging my head against this one too. Finally just solved it but requires altering some of the angucomplete-alt source. It also uses ng-model for two way data binding.

All you need to do is add

searchStr: '=ngModel',

to the directive's internal scope. Add right after

focusIn:"&"

You now have access to ng-model in in the angucomplete-alt directive.

like image 177
dylan Avatar answered Jan 17 '23 11:01

dylan