javascript - Post form using values filled by jquery in Angular -


i have form drop downs this:

<select id="relevance" class="form-control input-lg" ng-model="formdata.relevance"></select> 

i can fill these dropdowns using jquery maps json data appropriate dropdown this:

$.getjson("url/to/the/json", function(data) {  // values database  var rel_val = data[0].relevance;  // set fields using jquery $("#relevance").val(rel_val); 

this works great, if click on form submit button:

<button type="submit" id="submit_button" class="btn btn-primary btn-lg btn-block" ng-click="createtodo();">save changes</button> 

it not write database (postgres). know "createtodo()" works because if manually make changes dropdowns (so set me, not jquery) form submit data properly.

my "createtodo" looks this:

// create new todo $scope.createtodo = function(todoid) {     $http.post('/api/v1/todos', $scope.formdata)         .success(function(data) {             $scope.formdata = {};             $scope.tododata = data;             console.log(data);         })         .error(function(error) {             console.log('error: ' + error);         }); }; 

so, how can still submit form data using values set jquery instead of manually? have binding?

i have tried adding controller:

        $http.get('/api/v1/todos')         .success(function(data) {                  $scope.formdata.relevance = data[0].relevance;                  }) 

where ng-model ng-model = "formdata.relevance" , value of relevance comes data[0].relevance.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -