<form name="form" novalidate> <label name="email">Your email</label> <input type="email" name="email" ng-model="email" placeholder="Email Address"/> </form>
<input type="text" required />
<input type="text" ng-minlength="5" />
<input type="text" ng-maxlength="20" />
<input type="text" ng-pattern="[a-zA-Z]" />
<input type="email" name="email" ng-model="user.email" />
<input type="number" name="age" ng-model="user.age" />
<input type="url" name="homepage" ng-model="user.facebook_url" />
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>表单测试</title>
<link rel="stylesheet" href="">
<script type="text/javascript" src="angular.1.2.13.js"></script>
</head>
<body>
<div ng-controller="TestController">
<form name="testForm">
<input type="number" name="inputs" ng-test ng-model="obj.number">
<span ng-show="testForm.inputs.$error.test">good</span>
<span ng-hide="testForm.inputs.$error.test">bad</span>
<div>{{ testForm.inputs.$valid }}</div>
<div>{{ testForm.inputs.$invalid }}</div>
<div>{{ obj.number }}</div>
</form>
</div>
<script type="text/javascript" src="test5app.js"></script>
</body>
</html>
angular.module('myApp', []).controller('TestController', function($scope) {
$scope.obj = {
number: 34
}
}).directive('ngTest', function() {
return {
require: '?ngModel',
restrict: 'AE',
link: function($scope, iElm, iAttrs, ngModel) {
if (!ngModel) return;
ngModel.$parsers.push(function(viewValue) {
var num = parseInt(viewValue);
if (num >= 0 && num < 99) {
ngModel.$setValidity('test', true);
return viewValue
} else {
ngModel.$setValidity('test', false);
return undefined
}
})
}
}
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有