diff --git a/src/tooltip/test/tooltip.spec.js b/src/tooltip/test/tooltip.spec.js index bfaaf1e7dd..d2b7d7a2b9 100644 --- a/src/tooltip/test/tooltip.spec.js +++ b/src/tooltip/test/tooltip.spec.js @@ -132,6 +132,38 @@ describe('tooltip', function() { expect( elmBody.children().length ).toBe( 0 ); })); + describe('with specified enable expression', function() { + + beforeEach(inject(function ($compile) { + scope.enable = false; + elmBody = $compile(angular.element( + '
Selector Text
' + ))(scope); + scope.$digest(); + elm = elmBody.find('span'); + elmScope = elm.scope(); + + })); + + it('should not open ', inject(function () { + + elm.trigger('mouseenter'); + expect(elmScope.tt_isOpen).toBeFalsy(); + expect(elmBody.children().length).toBe(1); + + })); + + it('should open', inject(function () { + + scope.enable = true; + scope.$digest(); + elm.trigger('mouseenter'); + expect(elmScope.tt_isOpen).toBeTruthy(); + expect(elmBody.children().length).toBe(2); + + })); + }); + describe('with specified popup delay', function () { beforeEach(inject(function ($compile) { diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index fa301d9143..cf6256c7e3 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -116,6 +116,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap var appendToBody = angular.isDefined( options.appendToBody ) ? options.appendToBody : false; var triggers = getTriggers( undefined ); var hasRegisteredTriggers = false; + var hasEnableExp = angular.isDefined(attrs[prefix+'Enable']); // By default, the tooltip is not open. // TODO add ability to start tooltip opened @@ -131,6 +132,9 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap // Show the tooltip with delay if specified, otherwise show it immediately function showTooltipBind() { + if(hasEnableExp && !scope.$eval(attrs[prefix+'Enable'])) { + return; + } if ( scope.tt_popupDelay ) { popupTimeout = $timeout( show, scope.tt_popupDelay ); } else {