0

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.

here is the HTML used

<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.

2 Answers 2

0

I will try to improve my answer later.

But for a quick guess you might be able to use ng-if and let the controller handle if something should be listet.

<li ng-if="functionthatreturnstrueorfalsebasedonyourneeds" class="collection-item" ng-repeat="video in filterdVideo = (videos | filter:query) ">

Checkbox example can be found in the docs:

https://docs.angularjs.org/api/ng/directive/ngIf

Sign up to request clarification or add additional context in comments.

Comments

0

Fixed it by doing a filter:

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;
    };
})

but having an other issue now, when loading it in with data: https://stackoverflow.com/questions/29749006/angular-checklist-model-not-checking

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.