angularjs - meteor angular collection find method not working -
i'm trying optimize angular/meteor code. have collection
customers = new mongo.collection("customers");
and way displaying them was:
ng-repeat="customer in customercontroller.customers | filter: {customerstore: mystore} ">
and in customercontroller
this.customers = $meteor.collection(customers);
this approach (while works) starting take lot of memory on client's server adding more , more stores.
so tried filter server side before sending information client.
new code:
collection code same
customers = new mongo.collection("customers");
ng-repeat code different
ng-repeat="customer in customercontroller.getcustomers(mystore) ">
and controller has method:
this.getcustomers = function(findbystore){ return customers.find({customerstore.$ : findbystore}); }
the problem returns new collection each time, angular sees different object , tries re-render page.
https://docs.angularjs.org/error/$rootscope/infdig?p0=10&p1=%5b%5b%7b%22msg%22:%22fn:%20regularinterceptedexpression%22,%22newval%22:21,%22oldval%22:19%7d%5d,%5b%7b%22msg%22:%22fn:%20regularinterceptedexpression%22,%22newval%22:23,%22oldval%22:21%7d%5d,%5b%7b%22msg%22:%22fn:%20regularinterceptedexpression%22,%22newval%22:25,%22oldval%22:23%7d%5d,%5b%7b%22msg%22:%22fn:%20regularinterceptedexpression%22,%22newval%22:27,%22oldval%22:25%7d%5d,%5b%7b%22msg%22:%22fn:%20regularinterceptedexpression%22,%22newval%22:29,%22oldval%22:27%7d%5d%5d
one common mistake binding function generates new array every time called.
someone suggested try
return $meteor.collection(customers.find({'customerstore.$' : findbystore}));
but error
typeerror: first argument of $meteorcollection must function or have find function property.
Comments
Post a Comment