aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/directive
diff options
context:
space:
mode:
Diffstat (limited to 'test/ng/directive')
-rwxr-xr-xtest/ng/directive/ngIfSpec.js28
-rw-r--r--test/ng/directive/ngIncludeSpec.js30
-rw-r--r--test/ng/directive/ngRepeatSpec.js27
3 files changed, 85 insertions, 0 deletions
diff --git a/test/ng/directive/ngIfSpec.js b/test/ng/directive/ngIfSpec.js
index 3173f476..427bfd59 100755
--- a/test/ng/directive/ngIfSpec.js
+++ b/test/ng/directive/ngIfSpec.js
@@ -148,6 +148,34 @@ describe('ngIf', function () {
});
+describe('ngIf 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-if="true"><span test></span></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) {
+ var element = $compile('<div><div template></div></div>')($rootScope);
+ $rootScope.$apply();
+ expect(controller.flag).toBe(true);
+ dealoc(element);
+ });
+ });
+});
+
describe('ngIf animations', function () {
var body, element, $rootElement;
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;
diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js
index 9dde36e7..6584f31a 100644
--- a/test/ng/directive/ngRepeatSpec.js
+++ b/test/ng/directive/ngRepeatSpec.js
@@ -1058,6 +1058,33 @@ describe('ngRepeat', function() {
});
});
+describe('ngRepeat 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-repeat="l in [1]"><span test></span></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) {
+ var element = $compile('<div><div template></div></div>')($rootScope);
+ $rootScope.$apply();
+ expect(controller.flag).toBe(true);
+ dealoc(element);
+ });
+ });
+});
describe('ngRepeat animations', function() {
var body, element, $rootElement;