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

Empty option in select shows at last position when using ng-options and ng-if on the empty option #11061

Closed
latata opened this issue Feb 14, 2015 · 2 comments

Comments

@latata
Copy link

latata commented Feb 14, 2015

Check this: http://plnkr.co/edit/OtwP7LK34MuOeXDxiM3x?p=preview
When options are loaded from http request (in plunkr I use $timeout) the empty option apears at the last position when using ng-if on it. When I use ng-show everything works well.

This is on Angular 1.3
I'm also curious why it (the ng-if version) doesn't work on Angular 1.4 (I get TypeError: undefined is not a function on console - http://plnkr.co/edit/RpGCd4UpOVoi2VBfbWZb?p=preview)

@Narretz
Copy link
Contributor

Narretz commented Feb 16, 2015

I assume that's because ngIf's link fn is executed after ngOptions runs, so the options are already inserted.
I wonder what your use case for that is? Why do you need conditional empty options with ngIf?

@Narretz Narretz added this to the Ice Box milestone Feb 16, 2015
@Narretz
Copy link
Contributor

Narretz commented Sep 26, 2015

Duplicate of #12190

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

2 participants