This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +21
-2
lines changed
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -89,8 +89,8 @@ var ngIfDirective = ['$animate', function($animate) {
89
89
90
90
if ( toBoolean ( value ) ) {
91
91
if ( ! childScope ) {
92
- childScope = $scope . $new ( ) ;
93
- $transclude ( childScope , function ( clone ) {
92
+ $transclude ( function ( clone , newScope ) {
93
+ childScope = newScope ;
94
94
clone [ clone . length ++ ] = document . createComment ( ' end ngIf: ' + $attr . ngIf + ' ' ) ;
95
95
// Note: We only need the first/last node of the cloned nodes.
96
96
// However, we need to keep the reference to the jqlite wrapper as it might be changed later
Original file line number Diff line number Diff line change @@ -199,6 +199,25 @@ describe('ngIf and transcludes', function() {
199
199
dealoc ( element ) ;
200
200
} ) ;
201
201
} ) ;
202
+
203
+
204
+ it ( 'should use the correct transcluded scope' , function ( ) {
205
+ module ( function ( $compileProvider ) {
206
+ $compileProvider . directive ( 'iso' , valueFn ( {
207
+ restrict : 'E' ,
208
+ transclude : true ,
209
+ template : '<div ng-if="true"><div ng-transclude></div></div>' ,
210
+ scope : { }
211
+ } ) ) ;
212
+ } ) ;
213
+ inject ( function ( $compile , $rootScope ) {
214
+ $rootScope . val = 'transcluded content' ;
215
+ var element = $compile ( '<iso><span ng-bind="val"></span></iso>' ) ( $rootScope ) ;
216
+ $rootScope . $digest ( ) ;
217
+ expect ( trim ( element . text ( ) ) ) . toEqual ( 'transcluded content' ) ;
218
+ dealoc ( element ) ;
219
+ } ) ;
220
+ } ) ;
202
221
} ) ;
203
222
204
223
describe ( 'ngIf animations' , function ( ) {
You can’t perform that action at this time.
0 commit comments