码迷,mamicode.com
首页 > 其他好文 > 详细

directive ngPattern

时间:2017-06-14 18:16:05      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:for   label   att   work   ext   inpu   this   tle   direct   

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

用法:

<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

标签:for   label   att   work   ext   inpu   this   tle   direct   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!