Prevent calling parent when nested ui-sref

后端 未结 6 939

Let say I have nested DOMs and each has ui-sref for different angular-ui-router state. I want to click outer to only alert outer and c

6条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-18 22:42

    For a completely different purpose I had a stopEvent directive just waiting to be used for the nested ui-sref purpose.

    
      Outer
      Inner
    
    

    This is the directive

    app.directive('stopEvent', function () {
      return {
        restrict: 'A',
        link: function (scope, element, attr) {
          element.bind('click', function (e) {
            e.stopPropagation();
          });
        }
      };
    });
    

提交回复
热议问题