diff options
| author | Tobias Bosch | 2013-11-14 13:50:36 -0800 |
|---|---|---|
| committer | Vojta Jina | 2013-11-14 20:59:50 -0800 |
| commit | 90f87072e83234ae366cfeb3c281503c31dad738 (patch) | |
| tree | d969b74c0fe993900bc91e3e9f1d8004d238ac2c /test/ng/directive/ngIncludeSpec.js | |
| parent | c785918cbd245cc8ecf9a38e373b121c4e68a55b (diff) | |
| download | angular.js-90f87072e83234ae366cfeb3c281503c31dad738.tar.bz2 | |
fix($compile): accessing controllers of transcluded directives from children
Additional API (backwards compatible)
- Injects `$transclude` (see directive controllers) as 5th argument to directive link functions.
- `$transclude` takes an optional scope as first parameter that overrides the
bound scope.
Deprecations:
- `transclude` parameter of directive compile functions (use the new parameter for link functions instead).
Refactorings:
- Don't use comment node to temporarily store controllers
- `ngIf`, `ngRepeat`, ... now all use `$transclude`
Closes #4935.
Diffstat (limited to 'test/ng/directive/ngIncludeSpec.js')
| -rw-r--r-- | test/ng/directive/ngIncludeSpec.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/ng/directive/ngIncludeSpec.js b/test/ng/directive/ngIncludeSpec.js index beb29da7..aba71e44 100644 --- a/test/ng/directive/ngIncludeSpec.js +++ b/test/ng/directive/ngIncludeSpec.js @@ -439,6 +439,36 @@ describe('ngInclude', function() { }); }); +describe('ngInclude and transcludes', function() { + it('should allow access to directive controller from children when used in a replace template', function() { + var controller; + module(function($compileProvider) { + var directive = $compileProvider.directive; + directive('template', valueFn({ + template: '<div ng-include="\'include.html\'"></div>', + replace: true, + controller: function() { + this.flag = true; + } + })); + directive('test', valueFn({ + require: '^template', + link: function(scope, el, attr, ctrl) { + controller = ctrl; + } + })); + }); + inject(function($compile, $rootScope, $httpBackend) { + $httpBackend.expectGET('include.html').respond('<div><div test></div></div>'); + var element = $compile('<div><div template></div></div>')($rootScope); + $rootScope.$apply(); + $httpBackend.flush(); + expect(controller.flag).toBe(true); + dealoc(element); + }); + }); +}); + describe('ngInclude animations', function() { var body, element, $rootElement; |
