Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

ngOptions does not populate options through selectCtrl (hasOption doesn't work with ngOptions) #12915

Open
user291831 opened this issue Sep 22, 2015 · 2 comments

Comments

@user291831
Copy link

Regression(?) of #8761

Support for selectCtrl.hasOption in ngOptions was added in 1.3.x (09eeb48) but was lost as part of the ngOptions/select rewrite in 1.4.0(?) (408f89d)

JSBins - see console whilst changing select values.

1.3.1: http://jsbin.com/sifegicura/1/edit?html,js,output
1.4.5: http://jsbin.com/zufuzuweda/1/edit?html,js,output

I'm trying to write a directive which I can apply across a variety select fields and requires access to the options values that are available to the user using hasOption for check would make this much easier.

@Narretz
Copy link
Contributor

Narretz commented Sep 22, 2015

Hm, that's a pickle. Since ngOptions is now a standalone directive, there would need to be an interface between ngOptions and select that adds the ngOptions generated options to the selectCtrl. I'm not sure how easy this is, based on the fact that ngOptions now encodes the options differently. If you want to give a PR a shot, though, we'll be happy to look at it.

@Narretz Narretz added this to the Backlog milestone Sep 22, 2015
@Narretz Narretz changed the title ngOptions does not populate options through selectCtrl ngOptions does not populate options through selectCtrl (hasOptions doesn't work with ngOptions) Sep 22, 2015
@Narretz Narretz changed the title ngOptions does not populate options through selectCtrl (hasOptions doesn't work with ngOptions) ngOptions does not populate options through selectCtrl (hasOption doesn't work with ngOptions) Sep 22, 2015
@Narretz
Copy link
Contributor

Narretz commented Sep 28, 2015

We can overwrite the hasOption method, same as we do with writeValue etc.
However, two issues:

  • the function is undocumented, so we'd need to nail down that it should work a specific way
  • case in point: Should hasOption work with the scope.value or with the $viewValue? if you have a parser on ngModel that modifies the currently selected value, you cannot use it with scope.value

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants