mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
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.
This commit is contained in:
parent
97c7a4e379
commit
3fe4491a6b
2 changed files with 25 additions and 1 deletions
|
|
@ -1440,7 +1440,7 @@ function $CompileProvider($provide) {
|
|||
if (controllerDirectives) {
|
||||
forEach(controllerDirectives, function(directive) {
|
||||
var locals = {
|
||||
$scope: directive === newIsolateScopeDirective ? isolateScope : scope,
|
||||
$scope: directive === newIsolateScopeDirective || directive.$$isolateScope ? isolateScope : scope,
|
||||
$element: $element,
|
||||
$attrs: attrs,
|
||||
$transclude: boundTranscludeFn
|
||||
|
|
|
|||
|
|
@ -2480,6 +2480,30 @@ describe('$compile', function() {
|
|||
});
|
||||
|
||||
|
||||
it('should give the isolate scope to the controller of another replaced directives in the template', function() {
|
||||
module(function() {
|
||||
directive('testDirective', function() {
|
||||
return {
|
||||
replace: true,
|
||||
restrict: 'E',
|
||||
scope: {},
|
||||
template: '<input type="checkbox" ng-model="model">'
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
inject(function($rootScope) {
|
||||
compile('<div><test-directive></test-directive></div>');
|
||||
|
||||
element = element.children().eq(0);
|
||||
expect(element[0].checked).toBe(false);
|
||||
element.isolateScope().model = true;
|
||||
$rootScope.$digest();
|
||||
expect(element[0].checked).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should share isolate scope with replaced directives', function() {
|
||||
var normalScope;
|
||||
var isolateScope;
|
||||
|
|
|
|||
Loading…
Reference in a new issue