Angularjs: Ui-select ng-click in ui-select-choices
Angularjs: Ui-select ng-click in ui-select-choices
我正在尝试在选项中使用添加按钮,但问题是 ng-click 触发但选项未 selected。
<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>
我可以向该函数发送一些参数并处理这种情况,甚至 select 单击该项目索引的 link,以便模型采用正确的值,
或者像上面的工作示例一样把它带到外面......
但是我该如何正确处理这个问题,停止事件,select 选择不发送对象或其某些属性,然后再做剩下的事情?
$scope.setnewservice = function ($event) {
$event.stopPropagation();
// ??
}
在 ui-select 而不是 [= 上使用 ng-change 16=]ng-单击 ui-select-选项。改变这个:
ng-click="setnewservice()
至:
ui-select ng-model="datactrl.newservice.selected" theme="selectize" ng-disabled="disabled" style="width: 100%;" ng-change="setnewservice()>
您可以像这样将 on-select 属性添加到您的代码中:
on-select="setnewservice($item, $model)"
我正在尝试在选项中使用添加按钮,但问题是 ng-click 触发但选项未 selected。
<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>
我可以向该函数发送一些参数并处理这种情况,甚至 select 单击该项目索引的 link,以便模型采用正确的值, 或者像上面的工作示例一样把它带到外面......
但是我该如何正确处理这个问题,停止事件,select 选择不发送对象或其某些属性,然后再做剩下的事情?
$scope.setnewservice = function ($event) {
$event.stopPropagation();
// ??
}
在 ui-select 而不是 [= 上使用 ng-change 16=]ng-单击 ui-select-选项。改变这个:
ng-click="setnewservice()
至:
ui-select ng-model="datactrl.newservice.selected" theme="selectize" ng-disabled="disabled" style="width: 100%;" ng-change="setnewservice()>
您可以像这样将 on-select 属性添加到您的代码中:
on-select="setnewservice($item, $model)"