Home > Web Front-end > JS Tutorial > body text

AngularJS表单编辑提交功能实例_AngularJS

WBOY
Release: 2016-05-16 16:14:01
Original
1327 people have browsed it

研究了下高大上的AngularJS决定试试它的表单编辑提交功能,据说比JQuery强的不是一星半点。
好奇呀,试试吧。。。。。搞了好久,尼玛。。。靠。。靠。。靠。。尼玛 。。靠。。靠。。。。好吧,谁让我手欠呢。

搜索到了很多关于AngularJS Form的案例
如:

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

模仿着我要搞了个AngularJS Form,但是问题来了。。。。
发现初始化时候ng-model 跟 input 标签里的 value 不默契,冲突。。
后来想再AngularJS controller 里预先赋值 $scope.formData = {‘name':'张三'};
可以通过php程序把值赋到这个AngularJS controller里

复制代码 代码如下:


<script><br /> var formApp = angular.module('formApp', []);<br /> function formController($scope, $http) {<br /> $scope.formData = {'name':'张三','remark':'备注'};<br /> $scope.myForm = function() {<br /> $http({<br /> method : 'POST',<br /> url : '/role/edit',<br /> data : $.param($scope.formData), // pass in data as strings<br /> 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>


后来又搜啊搜 发现还有其他办法,这么个东东 ng-init=”formData.name='张三'”

复制代码 代码如下:


Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!