如何使用ng-click获取ui-select值

时间:2019-06-17 13:07:28

标签: javascript angularjs

html

<ui-select ng-model="item.payee" theme="selectize" class="input-group" style="min-width: 200px;">
    <ui-select-match placeholder="@lang('account.payee')" ng-cloak>@{{$select.selected.name}}</ui-select-match>
    <ui-select-choices
       refresh="searchPayees($select.search)" refresh-delay="500"
       repeat="person as person in people | filter: $select.search | limitTo: 10">
        <span class="badge" ng-class="{'badge-success': person.type == 'DEBTOR', 'badge-danger': person.type == 'CREDITOR'}" 
              ng-bind-html="person.type | uibTypeaheadHighlight:query"></span>
        <span ng-bind-html="person.name | highlight: $select.search"></span>
    </ui-select-choices>
</ui-select>
<input type="hidden" name="payee_id" ng-model="item.payee_id">
<input type="hidden" name="payee_type" ng-model="item.payee_type">
<input type="hidden" name="payee_name" ng-model="item.payee_name">
<button type="submit" class="btn btn-primary"
        ng-click="searchDate(sdate, edate)">
   <i class="fa fa-search"></i>
</button>

angularjs

$scope.searchDate = function (sdate, edate) {
    $scope.start_date = sdate instanceof Date ? moment(sdate).format('YYYY-MM-DD') : sdate;
    $scope.end_date = edate instanceof Date ? moment(edate).format('YYYY-MM-DD') : edate;;
    //$scope.params.query = date;
    if ($scope.item.payee) {
        $scope.item.payee_id = $scope.item.payee.id;
        $scope.item.payee_type = $scope.item.payee.type;
        $scope.item.payee_name = $scope.item.payee.name;
    }
    $scope.isSearch = true;
    $scope.fetch($scope.pg);
};

我的界面上有4列,分别是datepicker(开始日期和结束日期),ui-select下拉列表和搜索按钮。我想要实现的是用户可以根据日期和下拉值搜索数据库。上面的代码我无法获得ui-select下拉值

0 个答案:

没有答案