我试图弄清楚如何使用Angular搜索我的MongoDB数据。目前我已经设法用硬编码数据完成了一个可搜索的Angular应用程序,但我一直无法弄清楚如何将我的MongoDB数据传递给我的Angular设置。在下面的代码中,我展示了使用示例数据设置的Angular搜索,然后在底部设置了我的MongoDB模型。
我的问题是:如何显示我的MongoDB数据而不是我目前设置的数组?谢谢你的帮助!!
var app = angular.module('dreamjob', []);
app.controller('JobsController', function ($scope){
$scope.search = {};
$scope.selectedIndex = null;
$scope.selectedPerson = null;
$scope.jobs = [
{
"name": "Gregory Huffman",
"email": "Praesent@pedenec.net",
"birthdate": "2015-03-23T18:00:37-07:00",
"phonenumber": "07624 073918",
"address": "5880 Sed, Street",
"city": "Denderbelle",
"country": "Ethiopia"
},
{
"name": "Tad Vazquez",
"email": "dapibus.gravida@necimperdietnec.co.uk",
"birthdate": "2015-12-28T06:02:56-08:00",
"phonenumber": "(016977) 1036",
"address": "830-6354 Cubilia Rd.",
"city": "Sulzbach",
"country": "Liechtenstein"
},
]
})
<div class="form-group" >
<input type="text"
class="form-control"
id="name"
ng-model="search"
placeholder="Search name..."
/>
</div >
</form >
</div >
</div >
<table class="table table-bordered">
<tr>
<th>name</th>
<th>email</th>
<th>Birthdate</th>
</tr>
<tr ng-repeat="job in jobs | filter: search">
<td> {{job.name}} </td>
<td> {{job.email}} </td>
<td> {{job.birthdate}} </td>
</tr>
</table>
</div>
MONGO
var jobSchema = new mongoose.Schema({
name: String,
image: String,
description: String,
position: String,
location: String,
pay: String,