<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head> <script src="http://localhost:81/js/jquery.js">
</script>
<script src="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() {
          //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>

  

angular_form的更多相关文章

随机推荐

  1. 用Qemu模拟vexpress-a9 (四) --- u-boot引导kernel,用nfs挂载根文件系统

    环境介绍 Win7 64 + Vmware 11 + ubuntu14.04 32 u-boot 版本:u-boot-2015-04 Linux kernel版本:linux-3.16.y busyb ...

  2. vs安装mvc

    需要一个MVC框架和SP1补丁包,SP1补丁包的下载地址为:http://www.microsoft.com/downloads/details.aspx?FamilyID=27673c47-b3b5 ...

  3. struts2 基本用法

    Struts2必需库: commons-fileupload.jar.commons-io-1.3.2.jar.freemarker-2.3.16.jar.javassist-3.7.ga.jar.o ...

  4. codeforces 480A A. Exams(贪心)

    题目链接: A. Exams time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  5. HTML5本地存储localStorage与sessionStorage

    在最近的项目中用到了html5的本地存储,下面总结一下. 1.html5几种存储形式 本地存储(localStorage && sessionStorage) 离线缓存(applica ...

  6. POJ 2001 Shortest Prefix

    字典树基本题. 代码: #include <iostream> #include <cstdio> #include <cstring> #include < ...

  7. [汇编] 002基础知识-CPU和寄存器

    CPU是什么 当然这里的内存不仅仅指电脑上的内存,例如:我的金士顿8G内存,七彩虹1G独显,在这里来说,显卡也是有内存的(寄存器) CPU如何控制其它部件的? 问题:CPU是如何和电脑主机中其它芯片有 ...

  8. Jenkins遇到问题三:调整jdk版本不生效的解决办法

    由于项目统一环境的需要,需要将jdk版本从1.7降到1.6,通过修改“系统管理”菜单下的“系统设置”下的jdk环境变量: 将红圈中的路径修改为jdk6,如图所示:保存退出:发现通过”读取设置“和重启j ...

  9. find命令错误提示路径必须在表达式之前

    在某些版本的linux下,通过find查找当前目录下所有后缀名jpg的文件,命令为find ./ -iname *.jpg 会出现“find: 路径必须在表达式之前”的错误提示.解决的方法有两种 a. ...

  10. sp_executesql介绍和使用

    原文:http://www.cnblogs.com/wanyuan8/archive/2011/11/09/2243483.html execute相信大家都用的用熟了,简写为exec,除了用来执行存 ...