@@ -221,6 +221,13 @@ describe('<md-select>', function() {
221
221
expect ( selectedOptions ( el ) . length ) . toBe ( 0 ) ;
222
222
} ) ;
223
223
224
+ it ( 'supports circular references' , function ( ) {
225
+ var opts = [ { id : 1 } , { id : 2 } ] ;
226
+ opts [ 0 ] . refs = opts [ 1 ] ;
227
+ opts [ 1 ] . refs = opts [ 0 ] ;
228
+ setup ( 'ng-model="$root.model"' , opts , { renderValueAs : 'value.id' } ) ;
229
+ } ) ;
230
+
224
231
it ( 'renders model change by selecting new and deselecting old' , inject ( function ( $rootScope ) {
225
232
$rootScope . $apply ( 'model = "b"' ) ;
226
233
var el = setup ( 'ng-model="$root.model"' , [ 'a' , 'b' , 'c' ] ) ;
@@ -767,10 +774,10 @@ describe('<md-select>', function() {
767
774
return el ;
768
775
}
769
776
770
- function setup ( attrs , options ) {
777
+ function setup ( attrs , options , compileOpts ) {
771
778
var el ;
772
779
inject ( function ( $compile , $rootScope ) {
773
- var optionsTpl = optTemplate ( options ) ;
780
+ var optionsTpl = optTemplate ( options , compileOpts ) ;
774
781
var fullTpl = '<md-select-menu ' + ( attrs || '' ) + '>' + optionsTpl +
775
782
'</md-select-menu>' ;
776
783
el = $compile ( fullTpl ) ( $rootScope ) ;
@@ -786,12 +793,13 @@ describe('<md-select>', function() {
786
793
return setup ( attrs , options ) ;
787
794
}
788
795
789
- function optTemplate ( options ) {
796
+ function optTemplate ( options , compileOpts ) {
790
797
var optionsTpl = '' ;
791
798
inject ( function ( $rootScope ) {
792
799
if ( angular . isArray ( options ) ) {
793
800
$rootScope . $$values = options ;
794
- optionsTpl = '<md-option ng-repeat="value in $$values" ng-value="value">{{value}}</md-option>' ;
801
+ var renderValueAs = compileOpts ? compileOpts . renderValueAs || 'value' : 'value' ;
802
+ optionsTpl = '<md-option ng-repeat="value in $$values" ng-value="value">{{' + renderValueAs + '}}</md-option>' ;
795
803
} else if ( angular . isString ( options ) ) {
796
804
optionsTpl = options ;
797
805
}
0 commit comments