@@ -2144,6 +2144,52 @@ describe('ngOptions', function() {
2144
2144
} ) ;
2145
2145
2146
2146
2147
+ it ( 'should be possible to use ngIf in the blank option' , function ( ) {
2148
+ var option ;
2149
+ createSingleSelect ( '<option ng-if="isBlank" value="">blank</option>' ) ;
2150
+
2151
+ scope . $apply ( function ( ) {
2152
+ scope . values = [ { name : 'A' } ] ;
2153
+ scope . isBlank = true ;
2154
+ } ) ;
2155
+
2156
+ expect ( element . find ( 'option' ) . length ) . toBe ( 2 ) ;
2157
+ option = element . find ( 'option' ) . eq ( 0 ) ;
2158
+ expect ( option . val ( ) ) . toBe ( '' ) ;
2159
+ expect ( option . text ( ) ) . toBe ( 'blank' ) ;
2160
+
2161
+ scope . $apply ( function ( ) {
2162
+ scope . isBlank = false ;
2163
+ } ) ;
2164
+
2165
+ expect ( element . find ( 'option' ) . length ) . toBe ( 1 ) ;
2166
+ option = element . find ( 'option' ) . eq ( 0 ) ;
2167
+ expect ( option . text ( ) ) . toBe ( 'A' ) ;
2168
+ } ) ;
2169
+
2170
+
2171
+ it ( 'should be possible to use ngIf in the blank option when values are available upon linking' ,
2172
+ function ( ) {
2173
+ var options ;
2174
+
2175
+ scope . values = [ { name : 'A' } ] ;
2176
+ createSingleSelect ( '<option ng-if="isBlank" value="">blank</option>' ) ;
2177
+
2178
+ scope . $apply ( 'isBlank = true' ) ;
2179
+
2180
+ options = element . find ( 'option' ) ;
2181
+ expect ( options . length ) . toBe ( 2 ) ;
2182
+ expect ( options . eq ( 0 ) . val ( ) ) . toBe ( '' ) ;
2183
+ expect ( options . eq ( 0 ) . text ( ) ) . toBe ( 'blank' ) ;
2184
+
2185
+ scope . $apply ( 'isBlank = false' ) ;
2186
+
2187
+ options = element . find ( 'option' ) ;
2188
+ expect ( options . length ) . toBe ( 1 ) ;
2189
+ expect ( options . eq ( 0 ) . text ( ) ) . toBe ( 'A' ) ;
2190
+ }
2191
+ ) ;
2192
+
2147
2193
it ( 'should not throw when a directive compiles the blank option before ngOptions is linked' , function ( ) {
2148
2194
expect ( function ( ) {
2149
2195
createSelect ( {
0 commit comments