@@ -364,15 +364,15 @@ describe('$compile', function() {
364
364
$compileProvider . directive ( 'replace' , valueFn ( {
365
365
restrict : 'CAM' ,
366
366
replace : true ,
367
- template : '<div class="log" style="width: 10px" high-log>Hello: <<CONTENT>> </div>' ,
367
+ template : '<div class="log" style="width: 10px" high-log>Replace! </div>' ,
368
368
compile : function ( element , attr ) {
369
369
attr . $set ( 'compiled' , 'COMPILED' ) ;
370
370
expect ( element ) . toBe ( attr . $$element ) ;
371
371
}
372
372
} ) ) ;
373
373
$compileProvider . directive ( 'append' , valueFn ( {
374
374
restrict : 'CAM' ,
375
- template : '<div class="log" style="width: 10px" high-log>Hello: <<CONTENT>> </div>' ,
375
+ template : '<div class="log" style="width: 10px" high-log>Append! </div>' ,
376
376
compile : function ( element , attr ) {
377
377
attr . $set ( 'compiled' , 'COMPILED' ) ;
378
378
expect ( element ) . toBe ( attr . $$element ) ;
@@ -382,34 +382,34 @@ describe('$compile', function() {
382
382
383
383
384
384
it ( 'should replace element with template' , inject ( function ( $compile , $rootScope ) {
385
- element = $compile ( '<div><div replace>content </div><div>' ) ( $rootScope ) ;
386
- expect ( element . text ( ) ) . toEqual ( 'Hello: content ' ) ;
385
+ element = $compile ( '<div><div replace>ignore </div><div>' ) ( $rootScope ) ;
386
+ expect ( element . text ( ) ) . toEqual ( 'Replace! ' ) ;
387
387
expect ( element . find ( 'div' ) . attr ( 'compiled' ) ) . toEqual ( 'COMPILED' ) ;
388
388
} ) ) ;
389
389
390
390
391
391
it ( 'should append element with template' , inject ( function ( $compile , $rootScope ) {
392
- element = $compile ( '<div><div append>content </div><div>' ) ( $rootScope ) ;
393
- expect ( element . text ( ) ) . toEqual ( 'Hello: content ' ) ;
392
+ element = $compile ( '<div><div append>ignore </div><div>' ) ( $rootScope ) ;
393
+ expect ( element . text ( ) ) . toEqual ( 'Append! ' ) ;
394
394
expect ( element . find ( 'div' ) . attr ( 'compiled' ) ) . toEqual ( 'COMPILED' ) ;
395
395
} ) ) ;
396
396
397
397
398
- it ( 'should compile replace template' , inject ( function ( $compile , $rootScope , log ) {
399
- element = $compile ( '<div><div replace medium-log>{{ "angular" }} </div><div>' )
398
+ it ( 'should compile template when replacing ' , inject ( function ( $compile , $rootScope , log ) {
399
+ element = $compile ( '<div><div replace medium-log>ignore </div><div>' )
400
400
( $rootScope ) ;
401
401
$rootScope . $digest ( ) ;
402
- expect ( element . text ( ) ) . toEqual ( 'Hello: angular ' ) ;
402
+ expect ( element . text ( ) ) . toEqual ( 'Replace! ' ) ;
403
403
// HIGH goes after MEDIUM since it executes as part of replaced template
404
404
expect ( log ) . toEqual ( 'MEDIUM; HIGH; LOG' ) ;
405
405
} ) ) ;
406
406
407
407
408
- it ( 'should compile append template' , inject ( function ( $compile , $rootScope , log ) {
409
- element = $compile ( '<div><div append medium-log>{{ "angular" }} </div><div>' )
408
+ it ( 'should compile template when appending ' , inject ( function ( $compile , $rootScope , log ) {
409
+ element = $compile ( '<div><div append medium-log>ignore </div><div>' )
410
410
( $rootScope ) ;
411
411
$rootScope . $digest ( ) ;
412
- expect ( element . text ( ) ) . toEqual ( 'Hello: angular ' ) ;
412
+ expect ( element . text ( ) ) . toEqual ( 'Append! ' ) ;
413
413
expect ( log ) . toEqual ( 'HIGH; LOG; MEDIUM' ) ;
414
414
} ) ) ;
415
415
@@ -436,23 +436,23 @@ describe('$compile', function() {
436
436
}
437
437
} ) ) ;
438
438
439
- it ( 'should play nice with repeater when inline ' , inject ( function ( $compile , $rootScope ) {
439
+ it ( 'should play nice with repeater when replacing ' , inject ( function ( $compile , $rootScope ) {
440
440
element = $compile (
441
441
'<div>' +
442
- '<div ng-repeat="i in [1,2]" replace>{{i}}; </div>' +
442
+ '<div ng-repeat="i in [1,2]" replace></div>' +
443
443
'</div>' ) ( $rootScope ) ;
444
444
$rootScope . $digest ( ) ;
445
- expect ( element . text ( ) ) . toEqual ( 'Hello: 1; Hello: 2; ' ) ;
445
+ expect ( element . text ( ) ) . toEqual ( 'Replace!Replace! ' ) ;
446
446
} ) ) ;
447
447
448
448
449
- it ( 'should play nice with repeater when append ' , inject ( function ( $compile , $rootScope ) {
449
+ it ( 'should play nice with repeater when appending ' , inject ( function ( $compile , $rootScope ) {
450
450
element = $compile (
451
451
'<div>' +
452
- '<div ng-repeat="i in [1,2]" append>{{i}}; </div>' +
452
+ '<div ng-repeat="i in [1,2]" append></div>' +
453
453
'</div>' ) ( $rootScope ) ;
454
454
$rootScope . $digest ( ) ;
455
- expect ( element . text ( ) ) . toEqual ( 'Hello: 1; Hello: 2; ' ) ;
455
+ expect ( element . text ( ) ) . toEqual ( 'Append!Append! ' ) ;
456
456
} ) ) ;
457
457
458
458
@@ -494,8 +494,12 @@ describe('$compile', function() {
494
494
495
495
beforeEach ( module (
496
496
function ( $compileProvider ) {
497
- $compileProvider . directive ( 'hello' , valueFn ( { restrict : 'CAM' , templateUrl : 'hello.html' } ) ) ;
498
- $compileProvider . directive ( 'cau' , valueFn ( { restrict : 'CAM' , templateUrl :'cau.html' } ) ) ;
497
+ $compileProvider . directive ( 'hello' , valueFn ( {
498
+ restrict : 'CAM' , templateUrl : 'hello.html' , transclude : true
499
+ } ) ) ;
500
+ $compileProvider . directive ( 'cau' , valueFn ( {
501
+ restrict : 'CAM' , templateUrl :'cau.html'
502
+ } ) ) ;
499
503
500
504
$compileProvider . directive ( 'cError' , valueFn ( {
501
505
restrict : 'CAM' ,
@@ -930,9 +934,10 @@ describe('$compile', function() {
930
934
} ) ) ;
931
935
932
936
933
- it ( 'should work when widget is in root element' , inject (
937
+ it ( 'should work when directive is on the root element' , inject (
934
938
function ( $compile , $httpBackend , $rootScope ) {
935
- $httpBackend . expect ( 'GET' , 'hello.html' ) . respond ( '<span>3==<<content>></span>' ) ;
939
+ $httpBackend . expect ( 'GET' , 'hello.html' ) .
940
+ respond ( '<span>3==<span ng-transclude></span></span>' ) ;
936
941
element = jqLite ( '<b class="hello">{{1+2}}</b>' ) ;
937
942
$compile ( element ) ( $rootScope ) ;
938
943
@@ -942,9 +947,10 @@ describe('$compile', function() {
942
947
) ) ;
943
948
944
949
945
- it ( 'should work when widget is a repeater' , inject (
950
+ it ( 'should work when directive is a repeater' , inject (
946
951
function ( $compile , $httpBackend , $rootScope ) {
947
- $httpBackend . expect ( 'GET' , 'hello.html' ) . respond ( '<span>i=<<content>>;</span>' ) ;
952
+ $httpBackend . expect ( 'GET' , 'hello.html' ) .
953
+ respond ( '<span>i=<span ng-transclude></span>;</span>' ) ;
948
954
element = jqLite ( '<div><b class=hello ng-repeat="i in [1,2]">{{i}}</b></div>' ) ;
949
955
$compile ( element ) ( $rootScope ) ;
950
956
0 commit comments