AngularJS form editing and submission function instance _ AngularJS

Source: Internet
Author: User
This article describes how to modify the default value of an AngularJS form editing and submission function, if you need it, you can refer to and study AngularJS on the tall node and decide to try its form editing and submission function. It is said that it is better than JQuery.
Curious. Try it ..... After a long time, Nima... .. .. .. Nima .. .. By .... Well, who made me owe it.

I found many cases about AngularJS Form.
For example:

Http://www.angularjs.cn/A08j

Https://github.com/tiw/angularjs-tutorial

Https://github.com/tiw/angularjs-tutorial/blob/master/ng-form.markdown

Https://github.com/tiw/angularjs-tutorial/blob/master/ng-form2.markdown

Imitating that I want to build an AngularJS Form, but the problem is ....
It is found that during initialization, the ng-model and the value in the input tag do not have a tacit understanding or conflict ..
Later, I want to assign $ scope. formData = {'name': 'zhangsan'} To AngularJS controller '};
You can use the php program to assign the value to this AngularJS controller.

The Code is as follows:



Script
Var formApp = angular. module ('formapp', []);
Function formController ($ scope, $ http ){
$ Scope. formData = {'name': 'zhang san', 'remark': 'note '};
$ Scope. myForm = function (){
$ Http ({
Method: 'post ',
Url: '/role/edit ',
Data: $. param ($ scope. formData), // pass in data as strings
Headers: {'content-type': 'application/x-www-form-urlencoded'} // set the headers so angular passing info as form data (not request payload)
})
. Success (function (data ){
Console. log (data );
If (! Data. success ){
} Else {
}
});
};
}
Script


Later, I searched again and found there are other methods, such a Dongdong ng-init = "formData. name = 'zhang san '"

The Code is as follows:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.