@@ -354,27 +354,6 @@ angular.module('ui.select', [])
354
354
$document . off ( 'click' , onDocumentClick ) ;
355
355
} ) ;
356
356
357
- // Move transcluded elements to their correct position in main template
358
- transcludeFn ( scope , function ( clone ) {
359
- // See Transclude in AngularJS http://blog.omkarpatil.com/2012/11/transclude-in-angularjs.html
360
-
361
- // One day jqLite will be replaced by jQuery and we will be able to write:
362
- // var transcludedElement = clone.filter('.my-class')
363
- // instead of creating a hackish DOM element:
364
- var transcluded = angular . element ( '<div>' ) . append ( clone ) ;
365
-
366
- var transcludedMatch = transcluded . querySelectorAll ( '.ui-select-match' ) ;
367
- if ( transcludedMatch . length !== 1 ) {
368
- throw uiSelectMinErr ( 'transcluded' , "Expected 1 .ui-select-match but got '{0}'." , transcludedMatch . length ) ;
369
- }
370
- element . querySelectorAll ( '.ui-select-match' ) . replaceWith ( transcludedMatch ) ;
371
-
372
- var transcludedChoices = transcluded . querySelectorAll ( '.ui-select-choices' ) ;
373
- if ( transcludedChoices . length !== 1 ) {
374
- throw uiSelectMinErr ( 'transcluded' , "Expected 1 .ui-select-choices but got '{0}'." , transcludedChoices . length ) ;
375
- }
376
- element . querySelectorAll ( '.ui-select-choices' ) . replaceWith ( transcludedChoices ) ;
377
- } ) ;
378
357
}
379
358
} ;
380
359
} ] )
@@ -406,17 +385,8 @@ angular.module('ui.select', [])
406
385
rows . attr ( 'ng-repeat' , RepeatParser . getNgRepeatExpression ( repeat . lhs , '$select.items' , repeat . trackByExp ) )
407
386
. attr ( 'ng-mouseenter' , '$select.activeIndex = $index' )
408
387
. attr ( 'ng-click' , '$select.select(' + repeat . lhs + ')' ) ;
409
-
410
-
411
- transcludeFn ( function ( clone ) {
412
- var rowsInner = element . querySelectorAll ( '.ui-select-choices-row-inner' ) ;
413
- if ( rowsInner . length !== 1 )
414
- throw uiSelectMinErr ( 'rows' , "Expected 1 .ui-select-choices-row-inner but got '{0}'." , rowsInner . length ) ;
415
-
416
- rowsInner . append ( clone ) ;
417
- $compile ( element ) ( scope ) ;
418
- } ) ;
419
-
388
+
389
+ $compile ( element ) ( scope ) ;
420
390
$select . parseRepeatAttr ( attrs . repeat ) ;
421
391
422
392
scope . $watch ( '$select.search' , function ( ) {
@@ -453,6 +423,38 @@ angular.module('ui.select', [])
453
423
} ;
454
424
} ] )
455
425
426
+
427
+ . directive ( 'transinject' , function ( $compile , uiSelectMinErr ) {
428
+ return {
429
+ link : function ( scope , element , attrs , controller , transcludeFn ) {
430
+
431
+ if ( ! transcludeFn ) {
432
+ return ;
433
+ }
434
+
435
+ transcludeFn ( scope , function ( clone ) {
436
+
437
+ var injecting = clone ;
438
+
439
+ if ( attrs . transinject ) {
440
+ var cloneContainer = angular . element ( '<div>' ) . append ( clone ) ;
441
+ var cloneFiltered = cloneContainer . querySelectorAll ( attrs . transinject ) ;
442
+
443
+ if ( cloneFiltered . length !== 1 ) {
444
+ throw uiSelectMinErr ( 'transcluded' , "Expected 1 .xxx but got '{0}'." , cloneFiltered . length ) ;
445
+ }
446
+
447
+ injecting = cloneFiltered ;
448
+ }
449
+
450
+ element . empty ( ) ;
451
+ element . append ( injecting ) ;
452
+
453
+ } ) ;
454
+ }
455
+ } ;
456
+ } )
457
+
456
458
/**
457
459
* Highlights text that matches $select.search.
458
460
*
0 commit comments