1

I want to create custom directives instead of ng-mouseover and ng-mouseleave, since ng-mouseleave didnt work in chrome.

My requirement is when i mouseover, a popover should appear and when I mouseleave, it should close. The close functionality is not closing in few situations in chrome(the frequency of popover closing is inconsistent).

<div class="eleCalc" ng-mouseover="calcPopOver(i)" id="term{{i.Id}}" ng-mouseleave="hidePopOvers()">
                    {{calcNumbers(i)}}
</div>

calcPopOver function opens popup and hidePopOvers() closes.

Please help to create new directive.

Thanks

4
  • Have you searched for other people with this issue? I found this immediately, does it fix your issue? stackoverflow.com/questions/27687002/… Commented Oct 26, 2015 at 11:50
  • The issue might be something else because those two directives usually work in all common browsers. I would investiage the casue for this instead of implementing custom ones. Commented Oct 26, 2015 at 11:56
  • @BenHeymink Thanks for your reply. I know about this but it looks like client doesn't want to do settings in chrome. So I have to bring up new approach for the above. Can you help me? Commented Oct 26, 2015 at 11:58
  • @LordTribual This is something to do with settings in chrome. So, I am trying to build a new approach for the same functionality. Commented Oct 26, 2015 at 11:59

1 Answer 1

8

Yes you can use custom directive like below to achieve the functionality you want.

app.directive('domDirective', function () {
      return {
          restrict: 'A',
          link: function ($scope, element, attrs) {
              element.on('click', function () {
                  element.html('You clicked me!');
              });
              element.on('mouseenter', function () {
                  element.css('background-color', 'yellow');
              });
              element.on('mouseleave', function () {
                  element.css('background-color', 'white');
              });
          }
      };
  });

The working code pen for same is as below.

CodePen

For more detail on custom directive like this visit below link.

weblogs.asp.net

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer. I want On mouseenter, i need to call calcPopover(i) function. which creates a popup with data.and On mouseleave, I need to call hidepopovers() to close the popovers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.