加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angularjs:用户选择ui-select-choice中的ng-click

发布时间:2020-12-17 08:46:46 所属栏目:安全 来源:网络整理
导读:我试图在选项中使用添加按钮,但问题是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.sel
我试图在选项中使用添加按钮,但问题是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();
    // ??
}
在ui-select上使用ng-change而不是单击ui-select-choices.改变这个:
ng-click="setnewservice()

至:

ui-select ng-model="datactrl.newservice.selected" theme="selectize" ng-disabled="disabled" style="width: 100%;" ng-change="setnewservice()>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读