Skip to content

Instantly share code, notes, and snippets.

@jdx
Last active October 16, 2015 21:10
Show Gist options
  • Save jdx/f5a9adbf8123c252da82 to your computer and use it in GitHub Desktop.
Save jdx/f5a9adbf8123c252da82 to your computer and use it in GitHub Desktop.
'use strict';
angular.module('app', []);
angular.module('app')
.controller('TodoCtrl', function ($scope, TodoSvc) {
$scope.todos = [{title: 'Get paper'}, {title:'Mail rent check'}];
$scope.addTodo = function () {
TodoSvc.add($scope.newTodo)
.then(function () {
$scope.todos.push({title: $scope.newTodo});
$scope.newTodo = {};
});
}
});
angular.module('app')
.service('TodoSvc', function ($http) {
this.add = function (todo) {
return $http.post('/api/todos', todo);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment