The right way to display one to many models using Angular and Rails

To get better understanding of how Angular works with Rails I am
creating a simple todo app.This is my first week with Angular and I have
no idea how to use it correctly with rails.

An idea is following. I have a list of todos and when I click on todo I
get a list of tasks below which are associated with this todo list. You
can take a look on attached picture, maybe it will explain better what I
am trying to say here.

One "todo" has many "tasks". todo_id is a FK in the task model.

This is what I've done to display all todos:
<div data-ng-repeat="todo in todos" class="row todo" >
    <h2 class="col-xs-10" ng-click="changeVisibleState(">
     <i ng-click="deleteTodo(" class="glyphicon glyphicon-trash
     <div class="col-md-6 col-md-offset-2" ng-if="visible(">
        <div data-ng-repeat="task in todo.tasks" id="tasks"
            <h3 class="col-xs-10">{{task.title}}</h3>
            <i class="glyphicon glyphicon-trash"
      <-- form -->

As you see so far I get a list of tasks from todo but if I add a task or
delete one I have to reload a todo and I have no idea how to update html
on flight using Angular.

This is how I delete a todo (I hope it is not very ugly :slight_smile:
  Todo = $resource("/api/todos/:id", {id: "@id"}, {update: {method:
  $scope.todos = Todo.query()

  $scope.deleteTodo = (id) ->
    todo = (item for item in $scope.todos when is id)[0]
    $scope.$apply(removeFromArray($scope.todos, todo))

I would really appreciate if someone could give me a good example of how
Angular lives with Rails and how to use "Angular.resource" correctly.
Meanwhile I will be praying and reading angular sources :slight_smile:


If somebody is interested in solution - the easiest way to use properly

Task = $resource("/api/todos/:todo_id/tasks/:id", {todo_id: "@todo_id",
id:"@id"}, {update: {method:"PUT"}})

Task.query([params], success, error)[params], postData, success, error)

as example{todo_id:1,id:23}, {title:"new task", todo_id:1})