aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/compileSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/ng/compileSpec.js')
-rwxr-xr-xtest/ng/compileSpec.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js
index 7525806c..36a8b990 100755
--- a/test/ng/compileSpec.js
+++ b/test/ng/compileSpec.js
@@ -2502,6 +2502,70 @@ describe('$compile', function() {
expect(element.text()).toBe('parentTemplateText;childTemplateText;childContentText;babyTemplateText;')
});
});
+
+
+ it('should allow controller usage in pre-link directive functions with templateUrl', function () {
+ module(function () {
+ var Ctrl = function (log) {
+ log('instance');
+ };
+
+ directive('myDirective', function () {
+ return {
+ scope: true,
+ templateUrl: 'hello.html',
+ controller: Ctrl,
+ compile: function () {
+ return {
+ pre: function (scope, template, attr, ctrl) {},
+ post: function () {}
+ };
+ }
+ };
+ });
+ });
+
+ inject(function ($templateCache, $compile, $rootScope, log) {
+ $templateCache.put('hello.html', '<p>Hello</p>');
+
+ element = $compile('<div my-directive></div>')($rootScope);
+ $rootScope.$apply();
+
+ expect(log).toEqual('instance');
+ expect(element.text()).toBe('Hello');
+ });
+ });
+
+
+ it('should allow controller usage in pre-link directive functions with a template', function () {
+ module(function () {
+ var Ctrl = function (log) {
+ log('instance');
+ };
+
+ directive('myDirective', function () {
+ return {
+ scope: true,
+ template: '<p>Hello</p>',
+ controller: Ctrl,
+ compile: function () {
+ return {
+ pre: function (scope, template, attr, ctrl) {},
+ post: function () {}
+ };
+ }
+ };
+ });
+ });
+
+ inject(function ($templateCache, $compile, $rootScope, log) {
+ element = $compile('<div my-directive></div>')($rootScope);
+ $rootScope.$apply();
+
+ expect(log).toEqual('instance');
+ expect(element.text()).toBe('Hello');
+ });
+ });
});