I'm using typeahead's UI Bootstrap component and I want to force selection to validate my form. Is it possible to configure it to set the input invalid when 'typeahead-editable' is set to false and user enters a "bad" value or I should write a directive for this (but how ?)?
Thanks
UPDATE 2013-08-09 9:54: What do you think of the following solution :
var formValidatorsModule = angular.module('app.validator.formValidator', []); formValidatorsModule.directive('typeaheadForceSelection', function() { return { require : 'ngModel', link : function(scope, elm, attrs, ctrl) { ctrl.$parsers.push(function(viewValue) { if (viewValue == undefined) { ctrl.$setValidity('typeaheadForceSelection', false); } else { ctrl.$setValidity('typeaheadForceSelection', true); } return viewValue; }); } }; });