角显示复选框选中过滤器 [英] Angular show checkbox checked filter

查看:101
本文介绍了角显示复选框选中过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含视频列表的组对象
而当你编辑的对象,我给HTML的所有视频,在那里你可以在搜索列表。

I have a group object that contains a list of video And when you edit the object, i give the HTML a list of all videos, where you can search in.

但是,如果你不要搜索,我希望它仅显示选中的视频。

But if you don't search I want it to show only the videos that are checked.

下面是使用HTML

<div class="input-field">
    <input type="text" id="filter" ng-model="query" ng-change="hasVideos()" />
    <label for="filter"><i class="mdi-action-search"></i></label>
</div>

<ul class="collection">
    <li class="collection-item" ng-repeat="video in filterdVideo = (videos | filter:query) ">
        <p>
            <input type="checkbox" id="video_{{video.Id}}" checklist-model="group.Keywords" checklist-value="video.Id">
            <label for="video_{{video.Id}}">
                {{video.Title}}
            </label>
        </p>
    </li>
</ul>

所以,我怎样才能让这只能说明那里的复选框被选中的视频列表?当查询不为空忽略并显示所有。

So how can I make it that it only shows the video list where the checkbox is checked? and when the query isn't empty to ignore that and show all.

推荐答案

做一个过滤器固定它:

filter('filterStack', function () {
    return function (inputs, filterValues, showAll) {
        var output = [];
        if (showAll) return inputs;

        angular.forEach(inputs, function (input) {
            angular.forEach(filterValues, function (filterVal) {
                if (filterVal.Id == input.Id) {
                    output.push(input);
                }
            });
        });
        return output;
    };
})

但现在有一个问题,其他的,在数据​​加载时:角:清单模型不检查

这篇关于角显示复选框选中过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆