Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 3fe4491

Browse files
committedNov 8, 2013
fix($compile): correct isolate scope distribution to controllers
Fixes an issue when we didn't share the isolate scope with the controller of the directive from the isolate directive's template when this directive was replaced onto the isolate directive element.
1 parent 97c7a4e commit 3fe4491

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
 

‎src/ng/compile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ function $CompileProvider($provide) {
14401440
if (controllerDirectives) {
14411441
forEach(controllerDirectives, function(directive) {
14421442
var locals = {
1443-
$scope: directive === newIsolateScopeDirective ? isolateScope : scope,
1443+
$scope: directive === newIsolateScopeDirective || directive.$$isolateScope ? isolateScope : scope,
14441444
$element: $element,
14451445
$attrs: attrs,
14461446
$transclude: boundTranscludeFn

‎test/ng/compileSpec.js

+24
Original file line numberDiff line numberDiff line change
@@ -2480,6 +2480,30 @@ describe('$compile', function() {
24802480
});
24812481

24822482

2483+
it('should give the isolate scope to the controller of another replaced directives in the template', function() {
2484+
module(function() {
2485+
directive('testDirective', function() {
2486+
return {
2487+
replace: true,
2488+
restrict: 'E',
2489+
scope: {},
2490+
template: '<input type="checkbox" ng-model="model">'
2491+
};
2492+
});
2493+
});
2494+
2495+
inject(function($rootScope) {
2496+
compile('<div><test-directive></test-directive></div>');
2497+
2498+
element = element.children().eq(0);
2499+
expect(element[0].checked).toBe(false);
2500+
element.isolateScope().model = true;
2501+
$rootScope.$digest();
2502+
expect(element[0].checked).toBe(true);
2503+
});
2504+
});
2505+
2506+
24832507
it('should share isolate scope with replaced directives', function() {
24842508
var normalScope;
24852509
var isolateScope;

0 commit comments

Comments
 (0)