app.service('people', function ($http) { this.index = function (callback) { $http.get('http://127.0.0.1:8000/people').then(callback) } this.remove = function (item,callback) { $http.delete('http://127.0.0.1:8000/people/'+item._id).then(callback) } this.add = function (n,callback) { $http.post('http://127.0.0.1:8000/people',{name:n}).then(callback) } }) app.controller('peopleCtrl',function ($scope,people) { var self = this this.load = function () { people.index(function (people) { console.log(people) $scope.people_list = people.data }) } this.load() $scope.remove = function (item) { people.remove(item, self.load) } $scope.add = function () { console.log("adding") people.add($scope.name,self.load) $scope.name = '' } })