@@ -3578,7 +3578,7 @@ describe('$compile', function() {
3578
3578
controller : function ( $scope ) {
3579
3579
$scope . prop = $scope . prop || 'default' ;
3580
3580
this . getProp = function ( ) {
3581
- return $scope . prop ;
3581
+ return $scope . prop ;
3582
3582
} ;
3583
3583
} ,
3584
3584
controllerAs : 'ctrl' ,
@@ -4458,31 +4458,61 @@ describe('$compile', function() {
4458
4458
} ) ;
4459
4459
} ) ;
4460
4460
4461
- it ( 'should not overwrite @-bound property each digest when not present' , function ( ) {
4462
- module ( function ( $compileProvider ) {
4463
- $compileProvider . directive ( 'testDir' , valueFn ( {
4464
- scope : { } ,
4465
- bindToController : {
4466
- prop : '@'
4467
- } ,
4468
- controller : function ( ) {
4469
- var self = this ;
4470
- this . prop = this . prop || 'default' ;
4471
- this . getProp = function ( ) {
4472
- return self . prop ;
4473
- } ;
4474
- } ,
4475
- controllerAs : 'ctrl' ,
4476
- template : '<p></p>'
4477
- } ) ) ;
4461
+ describe ( 'should not overwrite @-bound property each digest when not present' , function ( ) {
4462
+ it ( 'when creating new scope' , function ( ) {
4463
+ module ( function ( $compileProvider ) {
4464
+ $compileProvider . directive ( 'testDir' , valueFn ( {
4465
+ scope : true ,
4466
+ bindToController : {
4467
+ prop : '@'
4468
+ } ,
4469
+ controller : function ( ) {
4470
+ var self = this ;
4471
+ this . prop = this . prop || 'default' ;
4472
+ this . getProp = function ( ) {
4473
+ return self . prop ;
4474
+ } ;
4475
+ } ,
4476
+ controllerAs : 'ctrl' ,
4477
+ template : '<p></p>'
4478
+ } ) ) ;
4479
+ } ) ;
4480
+ inject ( function ( $compile , $rootScope ) {
4481
+ element = $compile ( '<div test-dir></div>' ) ( $rootScope ) ;
4482
+ var scope = element . scope ( ) ;
4483
+ expect ( scope . ctrl . getProp ( ) ) . toBe ( 'default' ) ;
4484
+
4485
+ $rootScope . $digest ( ) ;
4486
+ expect ( scope . ctrl . getProp ( ) ) . toBe ( 'default' ) ;
4487
+ } ) ;
4478
4488
} ) ;
4479
- inject ( function ( $compile , $rootScope ) {
4480
- element = $compile ( '<div test-dir></div>' ) ( $rootScope ) ;
4481
- var scope = element . isolateScope ( ) ;
4482
- expect ( scope . ctrl . getProp ( ) ) . toBe ( 'default' ) ;
4483
4489
4484
- $rootScope . $digest ( ) ;
4485
- expect ( scope . ctrl . getProp ( ) ) . toBe ( 'default' ) ;
4490
+ it ( 'when creating isolate scope' , function ( ) {
4491
+ module ( function ( $compileProvider ) {
4492
+ $compileProvider . directive ( 'testDir' , valueFn ( {
4493
+ scope : { } ,
4494
+ bindToController : {
4495
+ prop : '@'
4496
+ } ,
4497
+ controller : function ( ) {
4498
+ var self = this ;
4499
+ this . prop = this . prop || 'default' ;
4500
+ this . getProp = function ( ) {
4501
+ return self . prop ;
4502
+ } ;
4503
+ } ,
4504
+ controllerAs : 'ctrl' ,
4505
+ template : '<p></p>'
4506
+ } ) ) ;
4507
+ } ) ;
4508
+ inject ( function ( $compile , $rootScope ) {
4509
+ element = $compile ( '<div test-dir></div>' ) ( $rootScope ) ;
4510
+ var scope = element . isolateScope ( ) ;
4511
+ expect ( scope . ctrl . getProp ( ) ) . toBe ( 'default' ) ;
4512
+
4513
+ $rootScope . $digest ( ) ;
4514
+ expect ( scope . ctrl . getProp ( ) ) . toBe ( 'default' ) ;
4515
+ } ) ;
4486
4516
} ) ;
4487
4517
} ) ;
4488
4518
} ) ;
0 commit comments