混淆使用mongoose填充数据和预填充数据

我是一个noob,并创build了一个集合 – 约会 – 其中有一个领域的工作人员。

工作人员是一个单独的集合,并有一个ID。

我试图显示所有约会的列表,并创build一个select下拉列表,它允许我改变职员。

我很困惑,因为我只是将该Appointment.staff设置为该员工的staff._id,但我希望select下拉列表显示他们的姓名。

我想我需要使用“填充”,但因为我是一个noob我不知道。

我怎样才能做到这一点?

这是约会列表的控制器

angular.module('MyApp') .controller('adminController', ['$scope', 'Appointment', '$state', '$rootScope' , '$stateParams', '$log', '$modal', 'Staff', function($scope, Appointment, $state, $rootScope, $stateParams, $log, $modal, Staff) { $scope.apps = Appointment.query(); $scope.staffList = Staff.query(); }]) 

下拉菜单的代码:

  <td> <select class="form-control" name="staff" ng-options="staff._id as staff.name for staff in staffList" ng-model="app.staff" ng-change="selectChange(app)" > <option></option> </select> </td> 

和约会的模式

 var mongoose = require('mongoose'); //Creates the appointments Schema for the User details var appointmentSchema = new mongoose.Schema({ name: String, email: { type: String, unique: true }, address_1: String, address_2: String, city: String, postcode: String, phone: String, appointment_date: String, token: String, StripeCustomerId: String, total_time: Number, total_charge: Number, lat: Number, lng: Number, staff: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Staff' }], jobDone: { type: Boolean, default: false} }); module.exports = mongoose.model('Appointment', appointmentSchema); 

和工作人员

 var mongoose = require('mongoose'); //Creates the appointments Schema for the Staff details var staffSchema = new mongoose.Schema({ name: String, email: { type: String, unique: true }, phone: Number, signup_date: Date, jobs: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Appointments' }], total_paid: { type: Number, default: 0 } }); module.exports = mongoose.model('Staff', staffSchema);