angularjs - (Help) Input prepopulated with db value, need to be able and save back to db -


very new angularjs (and javascipt in general).

here's have know works: 1) input db data 2) working function submits php

i have input populated data local mysql server (via $http, ng-repeat). (seemingly) since $scope of $http data response applies the ng-model belonging ng-repeat, dont know how pass input value submit function.

any ideas of simplest way this? once basic way of doing it, i'll explore more complex methods.

many thanks!

function usercardeditctrl ($scope, $routeparams, $http) { $scope.cardid = $routeparams.cardid; $http({     url: 'php/display.php?cardid=' + $scope.cardid,      method: "get"} )     .success(function(data) {         $scope.gut = data;     } ) var master = {     fname: 'j' };  $scope.run = function () {     $scope.form = angular.copy(master); };  $scope.sbmt = function () {     var send = $scope.form;     $scope.run();     $http({         method: 'post',         url: 'views/getlength.php',         data: send,         headers: {'content-type': 'application/x-www-form-urlencoded'},         transformrequest: function(obj) {             var str = [];             for(var p in obj)             str.push(encodeuricomponent(p) + "=" + encodeuricomponent(obj[p]));             return str.join("&");         }        })     .success(function(responsedata)         {             alert("length " + responsedata);         }     ) };  $scope.run(); } 

.

<form name="myform"> <input type="text" name="fname" id="fname" ng-model="gut.fname" /><br /> <button ng-click="sbmt()" >save</button>             </form>     


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -