1

I have a problem using directive multiple times on same page, if directive is defined multiple times on a page it calling only once.

Runnable demo: https://codepen.io/predatorz/pen/XWmPJwj

angular.module('DemoApp.directives', []).
  directive('popupDirective', function () {
      return {
      scope: {
        visible: '=?',
      },
      restrict: 'EA',
      template: '<div dx-popup="popupOptions"></div>',
      link: function (scope, elem, attrs) {
        scope.visible = scope.visible || false;
      },
      controller: function($scope){  
         console.log('controller is called');
         $scope.popupOptions = {
            width: 300,
            height: 250,
            showTitle: true,  
            title: 'Information',
            bindingOptions: {
                visible: "visible",
            }
        };
      }
    };
});

html:

<popup-directive visible="visiblePopup"/>
<popup-directive visible="visiblePopup2"/>
0

1 Answer 1

0

The issue was in using directive, it should be closed properly.

<popup-directive visible="visiblePopup"></popup-directive> 
<popup-directive visible="visiblePopup2"></popup-directive>
Sign up to request clarification or add additional context in comments.

Comments

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.