3

I have directive

class MyDirective

  constructor: (@$compile) ->
      return {
      scope:
        var1: "="
        var2: "="
      restrict: 'A'
      templateUrl: 'views/template.html'
      }

app.directive 'emDir', ['$compile', MyDirective]

template.html having this type

<div uib-popover-template="dynamicPopover.templateUrl" popover-trigger="mouseenter">
</div>

This directive repeats many times on my html with ng-repeat.

So, any repeating element has a popover on mouseenter. But I need to make popover only for some elements, not all.

I tried to do this

link = (scope, element, attrs) =>
    if scope.var1 < scope.var2
                    scope.$watch(
                          element.children().removeAttr('uib-popover-template')
                          element.children().removeAttr('popover-trigger')
                          $compile(element.children())(scope)
                    )

After that attributes removed, but popover still appears on mouseenter for all elements. This one does the same

compile: (element, attrs) =>
            pre: (scope, element, attrs) =>
                    if scope.var1 < scope.var2
                        element.children().removeAttr('uib-popover-template')
                        element.children().removeAttr('popover-trigger')

Also I tried

compile: (element, attrs) =>
       if attrs.var1 < attrs.var2
            element.children().removeAttr('uib-popover-template')
            element.children().removeAttr('popover-trigger')
            element.children().removeAttr('popover-popup-close-delay')

In this case popover disappears for all elements, but I need this only for some elements.

How can I do this?

pmk
  • 51
  • 3
  • If you can provide a working demo which demonstrates the above, that would help. – Hoa Jan 12 '17 at 08:02

0 Answers0