Front-end changes:
app.js: Uinsg $resource
/** * Created by Answer1215 on 12/9/2014. */ ‘use strict‘; function MainCtrl(People) { var vm = this; vm.selectedPerson = {}; vm.people = People.query(); vm.selectPerson = function(person) { var person = People.get({id: person._id}, function() { vm.selectedPerson = angular.copy(person); vm.selectedPerson.fullName = person.firstName + " " + person.lastName; }); } } angular.module(‘app‘,[ ‘ngResource‘ ]) .controller(‘MainCtrl‘, MainCtrl) .factory(‘People‘, function($resource) { var People = $resource(‘http://localhost:3000/people/:id‘, {id: ‘@id‘}, { update: { method: ‘PUT‘ } }); return People; });
Server side keep the same.
See last post: http://www.cnblogs.com/Answer1215/p/4187965.html
时间: 2024-10-27 10:20:13