metalaureate
metalaureate

Reputation: 7732

Triggering the keypress event on the angular boostrap ui typeahead directive

I'm using the angular-ui typeahead directive. I need to prebind the value of the field (easy), and then trigger the type-ahead search functionality, but there seems no way to do the latter programmatically.

Is there a way to emulate the keypress change event that must be triggering the lookup function?

Upvotes: 1

Views: 1303

Answers (1)

Tyler.z.yang
Tyler.z.yang

Reputation: 2450

Just look into the bootstrap-ui source code. It seems the bootstrap-ui use the ngModel.$parser to inspect the change of ngModel. BOOTSTRAP-UI source code(line: 190)

So I create a directive try to trigger $parser with

ngModel.$setViewValue('t');

And it works.

Here is DEMO DIRECTIVE PLUNKER.

And here is angular $parser&$setViewController document.

Hope this can work. : )

Upvotes: 4

Related Questions