簡體   English   中英

ng-change在ui-select2中不起作用

[英]ng-change is not working in ui-select2

當我在下拉菜單中更改選擇時,不會觸發ng-change以下是我的html和js代碼

                            <ui-select ng-model="DemandLine.SupplierId" theme="select2" ng-change="GetSupplierInfo()">
                                <ui-select-match allow-clear="true" placeholder="Select or search supplier in the list...">{{$select.selected.SupplierName}}</ui-select-match>
                                <ui-select-choices repeat="supplier.Id as supplier in (Suppliers | filter: $select.search)">
                                    <span ng-bind-html="supplier.SupplierName | highlight: $select.search"></span>
                                </ui-select-choices>
                            </ui-select>


$scope.GetSupplierInfo = function () {
    var _supplier = _.find($scope.Suppliers, function (data) { return (data.Id == $scope.DemandLine.SupplierId) });
    if (_supplier != undefined && _supplier != null && _supplier.Active == true) {
        $scope.DemandLine.SupplierId = _supplier.Id;
        $scope.DemandLine.Supplier = _supplier.SupplierName;
    }
    else {
        $scope.DemandLine.SupplierId = null;
        $scope.DemandLine.Supplier = null;
    }
    $scope.setStatus();
}

您應該使用on-select而不是ng-change這是一個角度指令

<ui-select ng-model="DemandLine.SupplierId" theme="select2" on-select="GetSupplierInfo()">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM