angular-ui/bootstrap — pull request #2297 by joshvillbrandt (2014-06-04 18:53:51+00:00)
Title: fix(typeahead): support for complex views and complex models

This is not in state to be merged, I'm simply sharing / continuing a conversation.

This commit adds back the ability to do object attribute labels when the model is also an object attribute. Three tests are affected by this:

* `typeahead tests initial state and model changes should correctly render initial state if the "as" keyword is used`
* this is currently broken - discussion below and feedback requested!
* `typeahead tests selecting a match should correctly update inputs value on mapping where label is not derived from the model`
* the select syntax was updated here from `state as` to `state.name as`
* ` typeahead tests non-regressions tests issue 786 - name of internal model should not conflict with scope model name`
* I'm not sure if this test applies anymore - I've commented it out

So the initial state of the typeahead is broken at the moment. In order to correctly render the ng-model viewValue, the whole object needs and not just the modelValue. If the modelValue is the object, then this shouldn't be a problem, otherwise the typeahead would need to fetch from the full object, probably from the server. Using the viewValue wouldn't be a sure way of finding the original object, so this would likely be a function passed in through an extra directive attribute for initializing a typeahead with this scenario.

Thoughts?