欢迎您访问我爱IT技术网,今天小编为你分享的javascript教程:【angularJS提交表单(form)】,下面是详细的讲解!
angularJS提交表单(form)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<script src="http://www.jb51.net/article/http://localhost:81/js/jquery.js">
</script>
<script src="http://www.jb51.net/article/http://localhost:81/js/angular.min.js">
</script>
<body ng-app="app">
<div ng-controller="TestCtrl">
<div ng-form test>
<input ng-model="a" type="email" />
<button ng-click="do()">查看</button>
</div>
</div>
<script>
app=angular.module("app",[]);
app.directive('test',function() {<br> //form表单的指令都有一个默认的控制器作为第四个参数
var link=function($scope, $element, $attrs, $ctrl) {
$scope.do=function() {
//$ctrl.$setDirty();
console.log($ctrl.$pristine); //form是否没被动过
console.log($ctrl.$dirty); //form是否被动过
console.log($ctrl.$valid); //form是否被检验通过
console.log($ctrl.$invalid); //form是否有错误
console.log($ctrl.$error); //form中有错误的字段
}
}
return {
compile: function() {
return link
},
require: 'form',
restrict: 'A'
}
});
app.controller('TestCtrl', function($scope){
//如果没有contrller,这东西还不会初始化..
});
</script>
</body>
</html>
关于angularJS提交表单(form)的用户互动如下:
相关问题:angularjs框架中,怎么处理表单的重复提交
答:AngularJS使得我们可以在不用额外努力的情况下轻松的处理客户端表单验证。虽然我... 首先我想说明我使用了 Foundation作为我的css框架,所以你 >>详细
相关问题:AngularJS表单实例问题
答:加个$scope.reset();代表页面初始化的时候先调用一次去掉的话,只有你点击按钮RESET的时候才会掉用 >>详细
相关问题:如何在js中提交form的表单
答: 点击的时候,就会去执行checkInput这个方法,如果为false就不会提交。 >>详细
- 【firefox】firefox浏览器不支持innerText的解决
- 【Extjs】Extjs学习过程中新手容易碰到的低级错误
- 【clearInterval】js clearInterval()方法的定义
- 【ComboBox】ComboBox 和 DateField 在IE下消失的
- 【dom】javascript dom追加内容实现示例-追加内容
- 【checkbox】让checkbox不选中即将选中的checkbox
- 【Array】js中更短的 Array 类型转换-类型转换
- 【append】append和appendTo的区别以及appendChil
- 【ExtJs】ExtJs 表单提交登陆实现代码-表单提交-
- 【ajax清除浏览器缓存】Ajax清除浏览器js、css、
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
