Permalink
Browse files

AngularJS Read with

1 parent ebf20f4 commit 0221aebd62e88445629debe4f132684686cf48ec @amejiarosario committed Oct 3, 2014
Showing with 9 additions and 14 deletions.
  1. +9 −14 views/index.ejs
View
@@ -37,26 +37,21 @@
// Services
//---------------
- .factory('Todos', function(){
- return [
- { name: 'AngularJS Directives', completed: true, note: 'add notes...' },
- { name: 'Data binding', completed: true, note: 'add notes...' },
- { name: '$scope', completed: true, note: 'add notes...' },
- { name: 'Controllers and Modules', completed: true, note: 'add notes...' },
- { name: 'Templates and routes', completed: true, note: 'add notes...' },
- { name: 'Filters and Services', completed: false, note: 'add notes...' },
- { name: 'Get started with Node/ExpressJS', completed: false, note: 'add notes...' },
- { name: 'Setup MongoDB database', completed: false, note: 'add notes...' },
- { name: 'Be awesome!', completed: false, note: 'add notes...' },
- ];
- })
+ .factory('Todos', ['$http', function($http){
+ return $http.get('/todos');
+ }])
//---------------
// Controllers
//---------------
.controller('TodoController', ['$scope', 'Todos', function ($scope, Todos) {
- $scope.todos = Todos;
+ Todos.success(function(data){
+ $scope.todos = data;
+ }).error(function(data, status){
+ console.log(data, status);
+ $scope.todos = [];
+ });
}])
.controller('TodoDetailCtrl', ['$scope', '$routeParams', 'Todos', function ($scope, $routeParams, Todos) {

1 comment on commit 0221aeb

@mentrie

I think it will be better if the services and controllers resides differently from the view to help communicate the tutorial in away that helps progression into bigger and more complex projects

Please sign in to comment.