angularjs - 带有功能的 ui-disable-choice

标签 angularjs ui-select

我正在尝试使用 ui-disable-choice 中的函数禁用 ui-select 中的选项。调用函数似乎不起作用。关于我做错了什么有什么想法吗?

用户界面选择

<ui-select 
            id="affSel--{{seat.sli_no}}"
            class="affSel"
            perf-no ="{{seat.perf_no}}"
            sli-no="{{seat.sli_no}}"
            ng-required="true"
            theme="bootstrap"
            on-select="changedAffiliate(mySeat.seat.sli_no, cartPerf.perf_no, seat.sli_no,seat)">

    <ui-select-match placeholder="-- Select person --">{{$select.selected.fname + ' ' + $select.selected.lname}}</ui-select-match>
    <ui-select-choices repeat="affiliate in affiliates | seatAffTypeFilter:seat.seatAff" 
                        ui-disable-choice="checkDisable(affiliate.customer_no,cartPerf.perf_no, seat.sli_no)">
        <div ng-bind-html="affiliate.fname + ' ' + affiliate.lname"></div>
        <small ng-show="affiliate.disabled">{{AffSelected}}</small>
        <small ng-show="affiliate.validation_pass_age == 'N'">{{invalidAffLbl}}</small>
    </ui-select-choices>
</ui-select>  

功能

$scope.checkDisable = function (customer_no, cur_perf_no, cur_sli_no) {
    $.each($scope.selectedAff, function (i) {
        if (this.customer_no == customer_no && this.perfNo == cur_perf_no && this.sli_no != cur_sli_no) {
            return true;
        } else {
            return false;
        }
    })
}

最佳答案

尝试

$scope.checkDisable = function (customer_no, cur_perf_no, cur_sli_no) {
    return false; //true;
}

如果这不起作用,则意味着不支持函数类型,但如果它起作用,那么您就会遇到代码问题...

大多数情况下,您没有捕获 $.each 函数的结果,从上下文来看,您似乎需要 _.find 而不是 $.each >

关于angularjs - 带有功能的 ui-disable-choice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44426528/

相关文章:

javascript - Angular,添加范围违反了我的指令

javascript - 在 AngularJS 中按名字的首字母过滤人员列表

javascript - 如何强制更新 ng-init ?

angularjs - 如何解决ParseError : 'import' and 'export' may appear only with 'sourceType: module' when importing UpgradeAdapter?

javascript - AngularJS 指令 (TypeScript)

angularjs 应用程序在 ui-select 字段中的占位符文本中不显示特殊字符

javascript - 如何在(AngularJS)ui-select 组件中设置搜索输入的最大长度?

javascript - Angularjs ui-select 标记不起作用

javascript - 我正在使用 Angular ui-select 进行下拉。如何获取 Controller 中选定的值?

javascript - Angularjs:如何使 ui-select 只有一种模型绑定(bind)方式?