Note that there are some explanatory texts on larger screens.

plurals
  1. POAngularJS inline edit inside of ng-repeat
    primarykey
    data
    text
    <p>Im working with AngularJS to display a table of app keys (app identifiers) and I would like to use an edit button to display a small form in that table row. Then the user can edit the fields and click "save" or "cancel" </p> <p>Demo: <a href="http://jsfiddle.net/Thw8n/">http://jsfiddle.net/Thw8n/</a></p> <p>I have the inline form working great. I click edit and a form appears. Cancel works great too. </p> <p>My problem is </p> <ol> <li>How do I connect the save button with a function that will make a $http call to an API</li> <li>How do I get the data from that row to send to the $http call?</li> <li>How do I disable <code>editMode</code> once the call comes back?</li> </ol> <p>Here is the actual code Im using in my controller (in the JSFiddle Im not able to make the http call). The first $http fills out the form, the editAppKey function is what is called by the save button.</p> <pre><code>function AppKeysCtrl($scope, $http, $location) { $http({ method: 'POST', url: 'http://' + $location.host() + ':1111/sys/appkey/save', data: { // How do I get the data? } }). success(function(data, status, headers, config) { $scope.appkeys = data; }). error(function(data, status, headers, config) { $scope.appkeys = [{ "appkey" : "ERROR", "name" : "ERROR", "created" : "ERROR" }]; }); $scope.editAppKey = function() { $http({ method: 'POST', url: 'http://' + $location.host() + ':1111/sys/appkeys' }). success(function(data, status, headers, config) { alert("Success!"); $scope.editMode = false; }). error(function(data, status, headers, config) { alert("There was an error."); }); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload