zoukankan      html  css  js  c++  java
  • directive ngPattern

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

    用法:

    <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+';
        });
  • 相关阅读:
    Codeforces 798C
    Codeforces 798B
    Codeforces 798A
    HDU
    HDU
    HDU
    加速cin的技巧
    Codeforces Gym
    Codeforces Gym
    Solutions to an Equation LightOJ
  • 原文地址:https://www.cnblogs.com/ms-grf/p/7009907.html
Copyright © 2011-2022 走看看