angular.module('todoList', ['ui.router'])
  .config(function($stateProvider, $urlRouterProvider) {
    $urlRouterProvider.otherwise('/todos');

    $stateProvider
      .state('todos', {
        url: '/todos',
        templateUrl: 'todos.html',
        controller: 'TodosCtrl',
        controllerAs: 'ctrl',
      })
      .state('notes', {
        url: '/todos/:id/notes',
        templateUrl: 'notes.html',
        controller: 'NotesCtrl',
        controllerAs: 'ctrl',
      })
      ;
  })

  .controller('TodosCtrl', ['TodosModel', function(TodosModel) {
    var ctrl = this;

    ctrl.newTodo = {
      content: ""
    };

    ctrl.addTodo = function(todo) {
      TodosModel.create(todo);
      ctrl.getTodos();

      ctrl.newTodo = {
        content: ""
      };
    };

    ctrl.updateTodo = function(todo) {
      TodosModel.update(todo);
      ctrl.getTodos();
    };

    ctrl.deleteTodo = function(todoId) {
      TodosModel.destroy(todoId);
      ctrl.getTodos();
    };

    ctrl.getTodos = function() {
      ctrl.todos = TodosModel.all();
    };

    ctrl.getTodos();
  }])

  .controller('NotesCtrl', ['$stateParams', '$state', 'TodosModel', function($stateParams, $state, TodosModel) {
    var ctrl = this;

    ctrl.getTodo = function(todoId) {
      ctrl.todo = TodosModel.fetch(todoId);
    }

    ctrl.deleteTodo = function(todoId) {
      TodosModel.destroy(todoId);
      $state.go('todos');
    };

    ctrl.updateDescription = function(todo) {
      ctrl.todo = TodosModel.update(todo);
    };

    ctrl.getTodo($stateParams.id);
  }])
  .service('TodosModel', function() {
    var service = this;

    // Fake Data
    var todos = [
      { id: 1, content: "Do the dishes", complete: false, description: "I have to do this by Thursday night." },
      { id: 2, content: "Clean my room", complete: true, description: "I have to do this by Thursday night." },
      { id: 3, content: "Walk the dog", complete: true, description: "I have to do this by Thursday night." },
      { id: 4, content: "Do the laundry", complete: false, description: "I have to do this by Thursday night." },
    ];

    service.all = function() {
      return todos;
    };

    service.fetch = function(todoId) {
      return todos.filter(function(item) { return item.id == todoId })[0];
    };

    service.create = function(todo) {
      todo.id = todos[todos.length - 1].id + 1;
      todo.complete = false;

      todos.push(todo);
    };

    service.update = function(todo) {
      for (var index in todos) {
        if (todos[index].id === todo.id) {
          todos[index] = todo;
          return;
        }
      };
    };

    service.destroy = function(todoId) {
      for (var index in todos) {
        if (todos[index].id === todoId) {
          todos.splice(index, 1);
          return;
        }
      }
    };

  })
  ;

@@ -488,16 +488,71 @@
 ;%0A  %7D)%0A%0A
+  .constant('ENDPOINT_URI', 'http://localhost:3000/')%0A%0A
   .contr
@@ -1612,16 +1612,17 @@
 ;%0A  %7D%5D)%0A
+%0A
   .servi
@@ -1629,32 +1629,42 @@
 ce('TodosModel',
+ %5B'$http',
  function() %7B%0A  
@@ -1649,32 +1649,37 @@
 http', function(
+$http
 ) %7B%0A    var serv
@@ -1699,546 +1699,81 @@
     
-// Fake Data%0A    var todos = %5B%0A      %7B id: 1, content: %22Do the dishes%22, complete: false, description: %22I have to do this by Thursday night.%22 %7D,%0A      %7B id: 2, content: %22Clean my room%22, complete: true, description: %22I have to do this by Thursday night.%22 %7D,%0A      %7B id: 3, content: %22Walk the dog%22, complete: true, description: %22I have to do this by Thursday night.%22 %7D,%0A      %7B id: 4, content: %22Do the laundry%22, complete: false, description: %22I have 
+service.all = function() %7B%0A      return $http.get(ENDPOINT_URI + %22
 to
- 
 do
- this by Thursday night.%22 %7D,%0A    %5D;%0A%0A    service.all = function() %7B%0A      return todos
+s%22)
 ;%0A  
@@ -1834,68 +1834,51 @@
 urn 
-todos.filter(function(item) %7B return item.id ==
+$http.get(ENDPOINT_URI + %22todos/%22 +
  todoId
- %7D)%5B0%5D
+)
 ;%0A  
@@ -1931,97 +1931,50 @@
     
-todo.id = todos%5Btodos.length - 1%5D.id + 1;%0A      todo.complete = false;%0A%0A      todos.push(
+return $http.post(ENDPOINT_URI + %22todos%22, 
 todo
@@ -2022,41 +2022,16 @@
 todo
-) %7B%0A      for (var index in
+Id,
  todo
-s
 ) %7B%0A
@@ -2040,306 +2040,175 @@
     
-  if (todos%5Bindex%5D.id === todo.id) %7B%0A          todos%5Bindex%5D = todo;%0A          return;%0A        %7D%0A      %7D;%0A    %7D;%0A%0A    service.destroy = function(todoId) %7B%0A      for (var index in todos) %7B%0A        if (todos%5Bindex%5D.id === todoId) %7B%0A          todos.splice(index, 1);%0A          return;%0A        %7D%0A      %7D
+return $http.put(ENDPOINT_URI + %22todos/%22 + todoId, todo);%0A    %7D;%0A%0A    service.destroy = function(todoId) %7B%0A      return $http.delete(ENDPOINT_URI + %22todos/%22 + todoId);
 %0A   
@@ -2215,14 +2215,15 @@
  %7D;%0A%0A  %7D
+%5D
 )%0A  ;%0A

Add ENDPOINT_URI constant and make TodosModel fetch from actual backend using service