vendredi 25 août 2017

Angular filter by checkbox, with checkbox

I want a filter for my program but i dont know how to do that.. google only gives me those searchfield filters or checkbox by names .. i dont get it.. so far..

    var app = angular.module('surveyApp', []);

app.controller('BackendCtrl', function($scope, $http){

        $scope.informations = [
            {
                id: 123,
                text: "first object",
                checkbox: 1,
            },
            {
                id: 222,
                text: "second object",
                checkbox: 1,
            },
            {
                id: 303,
                text: "third object",
                checkbox: 1,
            },
            {
                id: 412,
                text: "fourth object",
                checkbox: 0,
            },
            {
                id: 500,
                text: "fifth object",
                checkbox: 0,
            },
            {
                id: 666,
                text: "sixth object",
                checkbox: 1,
            },

        ];
   });

this is my angular data !

      <html>
<head>
    <title>Survey</title>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
</head>
<body ng-app="surveyApp" ng-controller="BackendCtrl">  

<div style="width: 150px; height: 40px; border:1px solid;">

    <input type="checkbox"/> All objects

</div>

<div>
    <table  border="1" style="margin: 0 auto;" ng-controller="BackendCtrl">
        <tr ng-repeat="item in informations">
            <td></td>
            <td></td>
            <td><input type="checkbox" ng-model="item.checkbox" ng-true-value="1" ng-false-value="0"/>cool</td>
        </tr>
    </table>
</div>

<script src="http://ift.tt/1GzOOSL"></script>
<script src="app.js"></script> 

</body>
</html>

the first checkbox should be my filter for item.checkbox.. if its true, all numbers should be given and if its false only the "not cool" objects.. greez pls help me




Aucun commentaire:

Enregistrer un commentaire