angularjs - Sending data form ng-repeat -


I create a form using ng-repeating modules:

  Form - {{$ Index}} - ID Form - {{$ index}} - value  

This is HTML of the form:

  & lt ; Input type = "text" id = "form-0-id" /> & Lt; Input type = "text" id = "form-0-value /"; input type = "text" id = "form-1-id" /> input type = "text" id = "form -1-value / & gt;  

I need to send the input text values ​​as form data, not as a query string. I have to use AngularJS to do this, I can not use the old classic button and refresh POST.

  form data-0-id: "x" form-0-value: "Y" form-1-id: "a" form-1-value: "b"  

exc ...

How can I get it? I already have a function that changes the data from the query string to create the data:

  app.config (function ($ httpProvider) {// use x-www-form -rlencoded Content-Type $ HttpProvider.defaults.headers.post ['Content-Type'] = 'App / X-www-Form-URLXD; Charset = UTF-8'; // $ http Service's Default Transformer Override $ httpProvider .defaults.transformRequest = [Function (data) {return angular.IJJX (data) & amp; and string (data)! == '[object f L] '? JQuery Kprm (data) data;}];});  

I think you can make this issue more complicated, you have items Is a list of

  var module = angular.module ('TestApp', []); Module. ('MyCtrl', function ($ http) {var self = this; self.items = [{prompt: 'prompt1', value: 'value1'}, {prompt: 'prompt2', value: 'Value2'}, {prompt: 'prompt3', value: 'value3'}] self.submitMe = function () {var url = 'http: // serverUrl' // sample post code: // $ Http.post (url, self.items); // debug: warning ('' data '+ url +' \ n '+ JSON.stringify (self.items));}}}};  < / Pre> 
  & lt; script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23 / Angular.min.js "& gt; & lt; / script & gt; & lt; div ng-app =" testApp "ng-controller =" MyCtrl as my "& gt; form ng-submit =" My.submitMe ( )> <> Lt; ul & gt; & lt; li ng- Repeatable = "item my.items" & gt; {{Item.prompt}} & lt; input type = "text" ng-model = " Item.value "/>  << ul> gt; & lt; button & gt; Save & lt; / button & gt; & lt; / form & gt; & lt 

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -