简体   繁体   中英

ng-model with condition and update in postgres

I have this data from my database

OrganizationViewsController data {"map":true,"deviceTypes":false,"configurations_alerts":true,"users":true,"organizations":false,"permissionsGroups":false,"configurations_users":true,"inventory":false,"interfaceTypes":false,"configurations_inventory":true,"deviceStatistic":false,"dashboard":true,"configurations_networks":true,"logs":false}

And in my view I have a checkbox to put true/false the value of each key of the data retrieve from db.

input type="checkbox" ng-bind="viewsData.indexOf('viewsData.configurations_')!=-1">

I'm getting problems with a input value named "configurations" to join the "configurations_networks, configurations_alerts, configurations_users, configurations_devices" into one cause the value of all will always be true or false depending of the value of the checkbox.

After selecting the checkbox the value I save my changes and I make a put request to save the updates. I need to update in my db this changes but how to do that in postgres?

I want something like

UPDATE organization_permissions_groups SET views = '{"configurations_%": checkboxValue}'::json WHERE id='df0417e3-ce36-41ca-9f13-f58c1a3a96f5';

How can I do this?

You don't connect angular with postgresql directly. You create a webservice with update method and use $http object to send the update request using POST method.

This is a similar question.

How to Update/Edit data in database with AngularJS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM