首页 > 其他 > 详细

directive ngPattern

时间:2017-06-14 17:54:32      阅读:370      评论:0      收藏:0      [点我收藏+]

用于设置输入框的正则表达式

用法:

<html ng-app="extendApp">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body ng-controller="extendController">
<div>
    <form name="form">
        <label for="regex">Set a pattern (regex string): </label>
        <input type="text" ng-model="regex" id="regex" />
        <br>
        <label for="input">This input is restricted by the current pattern: </label>
        <input type="text" ng-model="model" id="input" name="input" ng-pattern="regex" /><br>
        <hr>
        input valid? = <code>{{form.input.$valid}}</code><br>
        model = <code>{{model}}</code>
    </form>
</div>
<script src="framework/angular.js"></script>
<script src="js/aaa.js"></script>
</body>
</html>

script.js

angular.module("extendApp",[])
    .controller("extendController",function ($scope) {
        $scope.regex = ‘\\d+‘;
    });

 

directive ngPattern

原文:http://www.cnblogs.com/ms-grf/p/7009907.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!