我正在尝试使用 Meteor 和 Angular.js 的组合在我的 MongoDb 中获取某个地址的警告
在我的 html 文件中,我正在做
<div ng-controller = "myController as myCtrl">
{{myCtrl.warnings}}
{{myCtrl.getWarnings("123 Test Street, TestCity, TestState")}}
</div>
在我的 app.js 文件中:
Warnings = new Mongo.Collection("Warnings");
if (Meteor.isClient) {
var app = angular.module('ffprototype', [ 'angular-meteor' ]);
app.controller('myController', ['$window','$meteor', function($window, $meteor) {
this.warnings = $meteor.collection(Warnings);
this.getWarnings = function(findByAddress){
Warnings.find({address: findByAddress}).fetch();
}
}]);
}
我的 mongoDb 集合:
{
"_id": "3ixgxEMZDWGtugxA7",
"address": "123 Test Street, TestCity, TestState",
"warning": "Warning 1"
}
{
"_id": "HZH5FvCD5driBYSJz",
"address": "123 Test Street, TestCity, TestState",
"warning": "Warning 2"
}
html 网页的输出显示了整个警告集合(感谢{{currentDispatch.warnings}}
,但没有显示任何内容){{currentDispatch.getWarnings("123 Test Street, TestCity, TestState")}}