I am trying to get warnings for a specific address in my MongoDb using a combination of Meteor and Angular.js
In my html file I do
<div ng-controller = "myController as myCtrl"> {{myCtrl.warnings}} {{myCtrl.getWarnings("123 Test Street, TestCity, TestState")}} </div>
in the app.js file:
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(); } }]); }
My mongoDb collection:
{ "_id": "3ixgxEMZDWGtugxA7", "address": "123 Test Street, TestCity, TestState", "warning": "Warning 1" } { "_id": "HZH5FvCD5driBYSJz", "address": "123 Test Street, TestCity, TestState", "warning": "Warning 2" }
The html web page displays the entire Warnings collection (thanks {{currentDispatch.warnings}} , but nothing is displayed for {{currentDispatch.getWarnings("123 Test Street, TestCity, TestState")}}
angularjs mongodb meteor angular-meteor
Matt westlake
source share