过滤器很奇怪 - angularJS

时间:2015-11-20 06:11:13

标签: javascript angularjs search filter

我有两列用作项目列表,我可以在列表中添加内容,还可以搜索列表中的内容。 不知何故,我意识到它表现得很奇怪,如果我在搜索中输入1,它会在第1列中显示所有内容,但在第2列中它只会显示文本是否包含1,反之亦然第2列如果我使用除1/2之外的任何其他文本,则过滤器正常工作。

这是我的HTML

<div class="row input-output-panel">
    <div class="col-xs-6 col-sm-4 left-column">
        <div class="input-item">
            <input type="text" placeholder="ENTER ITEM" ng-model="item.name" class="enter-item">

            <select class="column-select" ng-model="item.pos" ng-options="option.value as option.name for option in typeOptions">
            </select>

            <button class="add-button" type="button" ng-click="addItem(item)">Add Item</button>
        </div>

        <div class="search-item">
            <label for="search">Search An Item</label>
            <div class="search-input">
                <input ng-model="query" type="text" placeholder="SEARCH" id="search"><span class="fa fa-search icon-search"></span>
            </div>
        </div>
    </div>

    <div class="col-xs-6 col-sm-4 item-columns column1">
        <table class="table-striped table-w-override">
            <tbody>
                <tr>
                    <th class="column-header">Column 1</th>
                </tr>
                <tr ng-repeat="item in items | filter:{ pos: 'column1' } | filter:query" ng-class-odd="odd" ng-class-even="even">
                    <td>{{item.name}}<span ng-click="remove(item)" class="remove-button fa fa-times"></span></td>
                </tr>
            </tbody>
        </table>
    </div>
    <!-- Optional: clear the XS cols if their content doesn't match in height -->
    <div class="clearfix visible-xs-block"></div>

    <div class="col-xs-6 col-sm-4 item-columns column2">
        <table class="table-striped table-w-override">
            <tbody>
            <tr>
                <th class="column-header">Column 2</th>
            </tr>
            <tr ng-repeat="item in items | filter:{ pos: 'column2' } | filter:query" ng-class-odd="odd" ng-class-even="even">
                <td>{{item.name}}<span ng-click="remove(item)" class="remove-button fa fa-times"></span></td>
            </tr>
            </tbody>
        </table>
    </div>
</div>

没有关于过滤器添加到脚本部分的内容。 我是否在俯视头部并再次错过了什么?

提前感谢您的帮助。

0 个答案:

没有答案