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: