Home > Web Front-end > JS Tutorial > AngularJS form editing and submission function example_AngularJS

AngularJS form editing and submission function example_AngularJS

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:14:01
Original
1408 people have browsed it

After studying the advanced AngularJS, I decided to try its form editing and submission function. It is said that it is not even a bit better than JQuery.
I'm curious, give it a try. . . . . It’s been a long time, damn. . . Depend on. . Depend on. . Depend on. . Nima. . Depend on. . Depend on. . . . Well, who makes me owe it?

I searched a lot of cases about AngularJS Form
Such as:

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

I was trying to imitate an AngularJS Form, but a problem arose. . . .
It is found that ng-model does not agree with the value in the input tag during initialization and conflicts. .
Later, I wanted to pre-assign the value in AngularJS controller $scope.formData = {'name':'Zhang San'};
The value can be assigned to this AngularJS controller through the php program

Copy code The code is as follows:


<script><br> var formApp = angular.module('formApp', []);<br> Function formController($scope, $http) {<br>            $scope.formData = {'name':'Zhang San','remark':'Remarks'};<br>            $scope.myForm = function() {<br>                $http({<br> Method : 'POST',<br>                                                                                                                                                                                                                                                                                                                                                                                             using headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload)<br>              })<br>                .success(function(data) {<br> console.log(data);<br> If (!data.success) {<br>                       } else {<br>                  }<br>                 });<br>         };<br> }<br> </script>




Later I searched and searched and found that there are other ways, such as ng-init=”formData.name=’Zhang San’”



Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
angular.js - angularJS ng-style用法
From 1970-01-01 08:00:00
0
0
0
angular.js - AngularJS form validation
From 1970-01-01 08:00:00
0
0
0
angular.js - Learning AngularJS
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template