angular-ui-树中可拖动节点中的可单击 link

Clickable link in draggable node in angular-ui-tree

angular-ui-tree 中,我正在寻找一种将 link 放入可拖动节点的方法。

现在发生的事情是,当我单击节点内的 link 时,它会启动 "holding" 整个节点来拖动它。

我看到了这个答案Angular JS (angular-ui-tree) ng-click conflict vs drag start event,但是它与我想做的不一样。在这个答案中,ng-click 绑定到节点,在我的例子中,节点内有多个 link。

下面是我的html:

    <div ui-tree="treeOptions" drag-delay="1000" id="tree-root">
      <ol ui-tree-nodes ng-model="filteredModules" data-nodrop>
        <li ng-repeat="module in filteredModules" ui-tree-node>
          <div ui-tree-handle ng-click="toggle(this)">
            <a class="btn btn-xs"><span class="glyphicon" ng-class="{'glyphicon-chevron-right': collapsed, 'glyphicon-chevron-down': !collapsed}"></span></a>
                {{module.name}}
          </div>
          <ol ui-tree-nodes ng-model="module.stages" data-nodrop ng-class="{hidden: collapsed}">
            <li ng-repeat="stage in module.stages" ui-tree-node>
              <div ui-tree-handle ng-click="toggle(this)">
                <a class="btn btn-xs"><span class="glyphicon" ng-class="{'glyphicon-chevron-right': collapsed, 'glyphicon-chevron-down': !collapsed}"></span></a>
                    {{stage.name}}
              </div>
              <div ui-tree-nodes ng-model="stage.cases" ng-class="{hidden: collapsed}">
                  <div ng-repeat="case in stage.cases" ui-tree-node>
                  <div ui-tree-handle>

                    <!-- HERE I HAVE TWO LINKS -->

                    <a href="/#/admin/cases/{{case._id}}">{{case.name}}</a>                       
                    <a href="/#/admin/cases/edit/{{case._id}}" class="pull-right btn btn-primary btn-xs"><span class="glyphicon glyphicon-edit"></span> Edit</a>                 
                  </div>
                  </div>
                </div>
            </li>
          </ol>
        </li>
      </ol>
    </div>

有没有办法在一个可拖动节点中放置多个 link?

提前致谢

像这样给链接添加 no-drag 属性:

<a data-nodrag href="/#/admin/cases/{{case._id}}">{{case.name}}</a>                       
<a data-nodrag href="/#/admin/cases/edit/{{case._id}}" class="pull-right btn btn-primary btn-xs"><span class="glyphicon glyphicon-edit"></span> Edit</a>

我遇到了同样的问题。我就是这样修复它的:

在angular-ui-tree.js

的第602行添加 a 元素
eventElmTagName = eventElm.prop('tagName').toLowerCase();
if (eventElmTagName == 'input' ||
eventElmTagName == 'textarea' ||
eventElmTagName == 'button' ||
eventElmTagName == 'i' ||
eventElmTagName == 'a' ||  //this would ignore 'a' elements while dragging
eventElmTagName == 'select') { 
return;
}

仅供参考 - 您在 span 元素中使用了字形。因此,如果您单击字形图标,您可能会遇到同样的问题。在上面的语句中添加 span 元素来解决这个问题。