angularjs - Angular nested repeat, save to database not working -


i'm using mean application, , want read data database, allow users edit it, , update changes database. working fine, except nested repeat, value's i'm able get, not save database.

code:

<div class="controls" ng-repeat="(key, module) in project.website.data.modules">                     <input type="checkbox" name="modules" value="{{key}}" data-ng-model="module.active" id="{{key}}"><label for="{{key}}"> module: {{key}} = {{module.active}}</label><br>                      <div class="features_settings" ng-repeat="(key2, feature) in module.data">                         <input type="text" name="data" value="{{key2}}" data-ng-model="feature" id="{{key2}}"><label for="{{key2}}"> feature {{key2}}, value= {{feature}}</label><br>                     </div>                 </div> 

gives result uniekewebsitefeature.data.title: (which correct because set default value "asdf")

feature title, value= asdf

mongoose schema:

website: {     active: { type: boolean },     data: {          domain: { type: string },         modules: {             aboutus: {                 active:{                      type: boolean,                     default: false                 },                 data: {                     title: {                          type: string,                         default: ""                     },titlerererere: {                          type: string,                         default: ""                     },                     text: {                          type: string,                         default: ""                     }                 }             },             contact: {                 active: {                      type: boolean,                     default: false                 },                 data: {                     fields: [                         {                             type: string,                             values: [string],                             label: string,                             placeholder: string                         }                     ],                     recipient: {                          type: string,                         default: ""                     }                 }             },             uniekewesitefeature: {                 active: {                      type: boolean,                     default: false                 },                 data: {                     title: {                          type: string,                         default: "asdf"                     },                     text: {                          type: string,                         default: ""                     }                 }             }         }     } } 

client controller

// update existing project     $scope.update = function() {                     var project = $scope.project;          project.$update(function() {             $location.path('projects/' + project._id);         }, function(errorresponse) {             $scope.error = errorresponse.data.message;         });     }; 

server controller

exports.update = function(req, res) { var project = req.project;  project = _.extend(project , req.body);  project.save(function(err) {     if (err) {         return res.status(400).send({             message: errorhandler.geterrormessage(err)         });     } else {         res.jsonp(project);     } }); 

};

when set module active/false, works fine , saves changes database, when save feature of module (which nested) doesn't save database, tough able value database.

any ideas?

finally fixed it, needed these changes:

<div class="controls" ng-repeat="(key, module) in project.website.data.modules">                     <label for="{{key}}"> module: {{key}} = {{module.active}}</label>                     <input type="checkbox" name="modules" value="{{key}}" data-ng-model="module.active" id="{{key}}"><br>                      <div class="features_settings" ng-repeat="(key2, feature) in module.data track $index">                         <label for="{{key2}}">feature: {{key2}} , value = {{module.data[key2]}}</label>                         <input type="text" class="form-control" name="features" data-ng-model="module.data[key2]" id="{{key2}}"><br>                     </div>                 </div> 

hopefully helps else in feature :)


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -