angular_form

时间:2022-03-14 16:15:25
<!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. iOS UIActivityIndicatorView

      UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle ...

    2. struts1

      1.简单应用示例 导入struts1的jar包,然后配置xml,写java和jsp /struts/WebRoot/Login.jsp <%@ page language="java& ...

    3. remot debug

      哎,首先吐槽一下,尼玛这是什么编辑器居然不能直接复制粘贴我写好的东西,废话不多说.为什么可以远程调试呢?首先JAVA运行依赖JVM,所以你可以把这种 远程debug想象成两个或者多个JVM之间按照约定 ...

    4. C&num;&period;Net 如何动态加载与卸载程序集(&period;dll或者&period;exe)1----C&num;中动态加载和卸载DLL

      我们知道在C++中加载和卸载DLL是一件很容易的事,LoadLibrary和FreeLibrary让你能够轻易的在程序中加载DLL,然后在任何地方卸载. 在C#中我们也能使用Assembly.Load ...

    5. Android开发之应用程序窗体显示状态操作(requestWindowFeature&lpar;&rpar;的应用)

      转自:http://www.cnblogs.com/salam/archive/2010/11/30/1892143.html 我们在开发程序是经常会需要软件全屏显示.自定义标题(使用按钮等控件)和其 ...

    6. Sans Serif 与 Serif 字体是什么意思?

      在西方国家罗马字母阵营中,字体分为两大种类:Sans Serif和 Serif,打字机体虽然也属于 Sans Serif,但由于是等宽字体,所以另外独立出 Monospace 这一种类,例如在Web中 ...

    7. 使用 IncrediBuild 提升 VisualStudio 编译速度

      我现在有一个 100M 的代码,需要快速去编译他,我寻找了很多方法,本文记录我找到的 IncrediBuild 用于提交编译速度. 如果一个项目存在很多不相互依赖的项目,那么使用 IncrediBui ...

    8. 两个有序数组长度分别为m&comma;n,最多m&plus;n次查找找出相同的数

      using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

    9. length、length&lpar;&rpar;、size&lpar;&rpar;区别 List与String相互转换

        字符串 数组 List对象 定义 String str = ""; String[] s = new String[5]; char[] s; List<String&g ...

    10. 在Docker中安装配置Oracle11g并实现数据持久化

      1.拉取镜像 docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g 镜像详情:https://dev.aliyun.com/ ...

    相关文章