如何使用typeahead与smarttable?

时间:2015-08-28 06:26:33

标签: angularjs angular-ui-typeahead smart-table

我创建了一个结合了预先输入功能的smarttable:

  <input type="text" class="form-control" ng-click="selectPerson()" ng-model="selectedPerson"
           bs-options="person.firstName for person in rowCollection" placeholder="Search for person" bs-typeahead>

    <table st-table="displayedCollection" st-safe-src="rowCollection" class="table table-striped">
        <thead>
        <tr>
            <th st-sort="firstName">first name</th>
            <th st-sort="lastName">last name</th>
            <th st-sort="birthDate">birth date</th>
            <th st-sort="balance">balance</th>
        </tr>

        </thead>
        <tbody>
        <tr ng-repeat="row in displayedCollection">
            <td>{{row.firstName}}</td>
            <td>{{row.lastName}}</td>
            <td>{{row.birthDate}}</td>
            <td>{{row.balance}}</td>
            <td>
                <button type="button" ng-click="removeItem(row)" class="btn btn-sm btn-danger">
                    <i class="glyphicon glyphicon-remove-circle">
                    </i>
                </button>
            </td>
        </tr>
        </tbody>
    </table>

目标是在搜索输入中搜索表格中的人物,选择名称然后显示在其下方的智能表格中。当我选择一个人时会发射:

$scope.selectPerson = function(){
    $scope.displayedCollection = $scope.selectedPerson;
    console.log($scope.displayedCollection );
}

但是,它不会显示表格中的人物。我如何修复它以便显示该人?

plunkr:http://plnkr.co/edit/NXEbl5?p=preview

0 个答案:

没有答案