我正在尝试在选项中使用添加按钮,但问题是 ng-click 触发但未选择该选项。
<ui-select ng-model="datactrl.newservice.selected" theme="selectize" ng-disabled="disabled" style="width: 100%;">
<ui-select-match placeholder="...">
<span ng-bind-html="$select.selected.name"></span>
</ui-select-match>
<ui-select-choices repeat="service in data.base_services | filter: $select.search">
<span ng-bind-html="service.name | highlight: $select.search"></span>
<!-- HERE NOT -->
<a href="" class="pull-right" ng-click="setnewservice()">
<i class="glyphicon glyphicon-plus-sign"></i>
</a>
<!-- ### -->
</ui-select-choices>
</ui-select>
<!-- here obviously works -->
<a href="" class="pull-right" ng-click="setnewservice()">
<i class="glyphicon glyphicon-plus-sign"></i>
</a>
我可以向函数发送一些参数并处理这种情况,即使选择该项目索引的单击链接,以便模型采用正确的值,或者像上面的工作示例一样将它带到外面......
但是我怎样才能正确处理这个问题,停止事件,选择选项而不发送对象或其某些属性,然后做剩下的事情?
$scope.setnewservice = function ($event) {
$event.stopPropagation();
// ??
}