0
如果用戶輸入值大於1並且輸入字段不包含正則表達式中定義的值,則只需顯示跨度。如果長度和ng模式不滿足,則隱藏元素角度
代碼:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example - example-ng-form-production</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-animate.js"></script>
<script type="text/javascript">
angular.element(document.getElementsByTagName('head')).append(angular.element('<base href="' + window.location.pathname + '" />'));
</script>
</head>
<body ng-app="formExample">
<script>
angular.module('formExample', [])
.controller('FormController', ['$scope', function($scope) {
$scope.userType = '';
$scope.regex = "#%<;'=";
}]);
</script>
<form name="myForm" ng-controller="FormController" class="my-form">
userType:
<input name="input" ng-model="userType" ng-pattern="regex && userType">
<span ng-show="userType && myForm.input.$valid">show me!</span>
<br>
</form>
</body>
</html>
它不起作用 –
給出一個模式的例子 –
在plunker中添加以及它在代碼中附加 –