@@ -394,7 +394,7 @@ uis.controller('uiSelectCtrl',
394
394
$scope . $uisSource = Object . keys ( originalSource ( $scope ) ) . map ( function ( v ) {
395
395
var result = { } ;
396
396
result [ ctrl . parserResult . keyName ] = v ;
397
- result . value = $scope [ ctrl . parserResult . sourceName ] [ v ] ;
397
+ result . value = $scope . peopleObj [ v ] ;
398
398
return result ;
399
399
} ) ;
400
400
} ;
@@ -408,7 +408,6 @@ uis.controller('uiSelectCtrl',
408
408
}
409
409
410
410
ctrl . refreshItems = function ( data ) {
411
- $scope . calculateDropdownPos ( ) ;
412
411
data = data || ctrl . parserResult . source ( $scope ) ;
413
412
var selectedItems = ctrl . selected ;
414
413
//TODO should implement for single mode removeSelected
@@ -420,6 +419,9 @@ uis.controller('uiSelectCtrl',
420
419
ctrl . setItemsFn ( filteredItems ) ;
421
420
}
422
421
}
422
+ if ( ctrl . dropdownPosition === 'auto' || ctrl . dropdownPosition === 'up' ) {
423
+ $scope . calculateDropdownPos ( ) ;
424
+ }
423
425
} ;
424
426
425
427
// See https://github.com/angular/angular.js/blob/v1.2.15/src/ng/directive/ngRepeat.js#L259
@@ -1855,21 +1857,39 @@ uis.service('uisRepeatParser', ['uiSelectMinErr','$parse', function(uiSelectMinE
1855
1857
self . parse = function ( expression ) {
1856
1858
1857
1859
1858
- //0000000000000000000000000000000000011111111100000000000000022222222222222003333333333333333333333000044444444444444444400000000000000005555500000666666666666600000000000000000000007777777770000000
1859
- var match = expression . match ( / ^ \s * (?: ( [ \s \S ] + ?) \s + a s \s + ) ? (?: ( [ \$ \w ] [ \$ \w ] * ) | (?: \( \s * ( [ \$ \w ] [ \$ \w ] * ) \s * , \s * ( [ \$ \w ] [ \$ \w ] * ) \s * \) ) ) \s + i n \s + ( [ \w ] + ) \s * ( | \s * [ \s \S ] + ?) ? (?: \s + t r a c k \s + b y \s + ( [ \s \S ] + ?) ) ? \s * $ / ) ;
1860
+ var match ;
1861
+ var isObjectCollection = / \( \s * ( [ \$ \w ] [ \$ \w ] * ) \s * , \s * ( [ \$ \w ] [ \$ \w ] * ) \s * \) / . test ( expression ) ;
1862
+ // If an array is used as collection
1863
+
1864
+ // if (isObjectCollection){
1865
+ //00000000000000000000000000000111111111000000000000000222222222222220033333333333333333333330000444444444444444444000000000000000556666660000077777777777755000000000000000000000088888880000000
1866
+ match = expression . match ( / ^ \s * (?: ( [ \s \S ] + ?) \s + a s \s + ) ? (?: ( [ \$ \w ] [ \$ \w ] * ) | (?: \( \s * ( [ \$ \w ] [ \$ \w ] * ) \s * , \s * ( [ \$ \w ] [ \$ \w ] * ) \s * \) ) ) \s + i n \s + ( ( [ \w ] + ) ? \s * ( | \s * [ \s \S ] + ?) ) ? (?: \s + t r a c k \s + b y \s + ( [ \s \S ] + ?) ) ? \s * $ / ) ;
1867
+
1868
+ // 1 Alias
1869
+ // 2 Item
1870
+ // 3 Key on (key,value)
1871
+ // 4 Value on (key,value)
1872
+ // 5 Collection expresion (only used when using an array collection)
1873
+ // 6 Object that will be converted to Array when using (key,value) syntax
1874
+ // 7 Filters that will be applied to #6 when using (key,value) syntax
1875
+ // 8 Track by
1860
1876
1861
1877
if ( ! match ) {
1862
1878
throw uiSelectMinErr ( 'iexp' , "Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'." ,
1863
1879
expression ) ;
1864
1880
}
1881
+ if ( ! match [ 6 ] && isObjectCollection ) {
1882
+ throw uiSelectMinErr ( 'iexp' , "Expected expression in form of '_item_ as (_key_, _item_) in _ObjCollection_ [ track by _id_]' but got '{0}'." ,
1883
+ expression ) ;
1884
+ }
1865
1885
1866
1886
return {
1867
1887
itemName : match [ 4 ] || match [ 2 ] , // (lhs) Left-hand side,
1868
1888
keyName : match [ 3 ] , //for (key, value) syntax
1869
- source : $parse ( ! match [ 3 ] ? match [ 5 ] + ( match [ 6 ] || '' ) : match [ 5 ] ) , //concat source with filters if its an array
1870
- sourceName : match [ 5 ] ,
1871
- filters : match [ 6 ] ,
1872
- trackByExp : match [ 7 ] ,
1889
+ source : $parse ( ! match [ 3 ] ? match [ 5 ] : match [ 6 ] ) ,
1890
+ sourceName : match [ 6 ] ,
1891
+ filters : match [ 7 ] ,
1892
+ trackByExp : match [ 8 ] ,
1873
1893
modelMapper : $parse ( match [ 1 ] || match [ 4 ] || match [ 2 ] ) ,
1874
1894
repeatExpression : function ( grouped ) {
1875
1895
var expression = this . itemName + ' in ' + ( grouped ? '$group.items' : '$select.items' ) ;
0 commit comments