0

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?

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

4 Comments

I know I'm just saying that i sent to my rest api something like {"configurations": false} and i want to update all "configurations_% in my database understand?
And I also need with ng-model to get the value of configurations_% from db to verifity if i put my checkbox at true/false
Sorry I still don't see where is the problem. You bind the model to the http service and the model to your view. So if use the service to update the db, the model and the view is also update
In my nog-model I want to put the valor of my var values configuations_alerts, configurations_networks, configurations_users, configurations_devices into a checkbox. This 4 options have the same value always and when i put my checkbox to true/false i want to reflect that in my database.. so i dont know to create that query for the part of "configuration_%" understand? I want something dinamic.. and dont mention every configuration_key ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.