Hello, I have some experience with AngularJS but the more I learn, the more I realize how much I don't know.
I want to create a simple autocomplete directive based on existing jquery plugin (from uikit frontend framework - http://getuikit.com/docs/autocomplete.html). And I can do it in many different ways but I'd like to know the correct, ideal way. My main problem is I don't know if I should use ngModelController or not. The autocomplete plugin must be set on an `input` element, but if I use an input element with `ng-model` I get one formatter set by default. And this formatter cause a problem. That's the case: In controller I set (it comes from the server response): $scope.user = { id: '1' name: 'John' } After assignment the value goes to the formatters pipeline, but the input's default formatter ruins it because it uses `toString` method, so the result is `[object Object]`. I could do ngModel.$formatters = [myFormatter], but it's probably a bad solution, because it overrides all already existing formatters. Another problem is with `change` event. By default $parsers are called every time I type something in my input, but I'd like to run parsers only when I call `ngModel.$setViewValue`, what means I want to do it only when I select an item from suggestions dropdown. I can switch off input 'change' event, but again it is bad solution. It is my currently working code with this bad things (with `ngModel.$formatters = [myFormatter]` and `elem.off('change')`): http://jsfiddle.net/aartek/fenbh3ug/ So I'd like to ask you how should I write this directive in proper way? Should I use `ngModelController` or not? Also, in my example` $modelValue` and `$viewValue` are different - is it correct? I hope you'll give me some advices. -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To post to this group, send email to angular@googlegroups.com. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.