0

Basically I'm making a todo list with angular and I want to display the how many items have been marked as done I have an array object of Lists and each list has a collection of list items called todos like so:

[{listName: "ESSENTIALS", newTodoName:"", newTodoQ:"0", todos: [
                        { taskName : "Comb" , quantity: 1,  isDone : false , id: "comb" }                                               ]},
{listName: "TOILETRIES", newTodoName:"", newTodoQ:"0", todos: [
                        { taskName : "Tooth Brush" , quantity: 1,  isDone : false , id: "toothbrush"},
                        { taskName : "Tooth paste" , quantity: 6,  isDone : false, id: "toothpaste" },
                        { taskName : "Deodorant" , quantity: 3, isDone : false, id: "deodorant" }
                                                                                    ]}];

So I have two ng-repeats.. One repeats the Lists then another inside of it prints out each list item. I have an H1 and next to the title I want to have the the items that were marked isDone as true next to the total amount of records to show how many items you have left. As you can see I started to code up a filter but I believe it's wrong I keep getting: "Syntax Error: Token 'undefined' is unexpected, expecting [}] at column null of the expression [ (list.todos |] starting at [{4}]." which I'm not really sure what that means...my fourth item is blank? Yet I have all my todos there and they are not blank. Is my filter wrong? or a better way to do this?

  <div class='row' ng-repeat="list in lists">
        <h1 class='centerTitle'>{{list.listName}} <span class="listCounter"> {{ (list.todos | filter:{todos: {isDone: true}}: true).length }} / {{list.todos.length}}</span></h1>

      <ul ui-sortable="todoSortable" ng-model="list.todos">
                                        <li  ng-class="{taskDone: todo.isDone}" class="todoTask" ng-repeat="todo in list.todos | orderBy: 'isDone' "></li>
  <div>

1 Answer 1

2

Can you try:

<h1 class='centerTitle'>{{list.listName}} <span class="listCounter"> {{ (list.todos | filter: {isDone: true}).length }} / {{list.todos.length}}</span></h1>
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much!
No problem at all :)

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.