angularjs - Make checkbox checked when db is updated in angular-meteor -


i listing menus settings collection check box. like this

when check menu pushed user collection menu's id.

but when navigate other page or refresh page checked check box gets unchecked itself. want avoid that.

here menus listed settings collection checked condition checked users collection, whether menu pushed or not.

my settings collection looks this:

{     "_id" : "gdfahpot5fxw78aw5",     "name" : "url",     "description" : "https://docs.mongodb.org/manual/reference/method/db.collection.update/",     "type" : "url",     "tag" : "this demo of url selected",     "status" : false } 

and user collection this:

"settings" : [      {         "_id" : "gdfahpot5fxw78api",         "name" : "image",         "description" : "uploads/images-ihdszya8xqhsgfbo5-prof.jpg",         "tag" : "this demo image",         "type" : "image",         "status" : false     },      {         "_id" : "gdfahpot5fxw78aw5",         "name" : "url",         "description" : "https://docs.mongodb.org/manual/reference/method/db.collection.update/",         "tag" : "this demo of url selected",         "type" : "url",         "status" : true     }] 

my html goes this:

  <div layout-gt-sm="row"  ng-repeat="detail in settingctrl.generalsettings">         <md-checkbox aria-label="checkbox 1"  ng-model="detail.status" ng-change="dynamicsettingsctrl.getclicked(detail._id)">                 <p> {{detail.name}} {{ detail.data.cb1 }}</p>         </md-checkbox>     </div> 

this client side js:

self.getclicked = (settingid) => {     self.dataarry = {};     self.datachk = {};      // self.currentuser = {};      console.log(settingid)      meteor.call("updatesettings", settingid, function(error, result) {         if (error) {             toastservice.gettoastbox($mdtoast, 'something went error!unable add details', 'error-toast');         } else {             //self.currentuser = {};             toastservice.gettoastbox($mdtoast, 'details added !', 'success-toast');         }     }); } 

and server side js:

updatesettings: function(generalvalue) {     let userid = meteor.userid();     let settingsdetails = generalsettings.findone({"_id": generalvalue});     meteor.users.update(         {_id: userid},         {             $push:              {                 "settings":                  {                     "_id": generalvalue,                     "name": settingsdetails.name,                     "description": settingsdetails.description,                     "tag": settingsdetails.tag,                     "type": settingsdetails.type,                     "status": settingsdetails.status                 }             }         })     } 


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -