मैं अपने MongoDB में एक निश्चित पते के लिए चेतावनी प्राप्त करने के लिए कोशिश कर रहा हूँ के आधार पर की गई, उल्का और 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"
}
एचटीएमएल वेबपेज से उत्पादन पूरे चेतावनी संग्रह ({{currentDispatch.warnings}}
करने के लिए धन्यवाद दिखाता है, लेकिन कुछ भी नहीं है आप इस
this.getWarnings = function(findByAddress){
$meteor.object(Warnings, { address: findByAddress }, false); // passing false here to not update the collection from changes in the client
}
यदि मैं ऐसा करता हूं, तो क्या मैं ऑटो-प्रकाशित सुविधाओं को नहीं हटाऊंगा? 'this.warnings = $ meteor.collection (चेतावनी); 'डेटाबेस को स्वचालित रूप से अपडेट को धक्का देता है, लेकिन जब मुझे कुछ" वापस "करना पड़ता है तो वह खो नहीं जाता है? –
आप सही हैं, मेरा संपादन देखें – tmaximini
धन्यवाद, जब मैं घर जाता हूं तो मैं इसे आज़माउंगा और यदि यह काम करता है तो मैं स्वीकार करूंगा और आपको दस्तावेज के अनुसार –