In this example of Ng-Pattern, We will use this to validate the input value. As we will have textbox for age where we want only two digit numbers so added regex variable in score and html likeSee the code
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script>
</head>
<body ng-app="app">
<div ng-controller="myController">
<h2>Enter age between 1 to 2 digits only</h2>
<ng-form name="myForm">
Age :
<input type="text" ng-model="age" name="age" ng-pattern="regEx" />
<br />
<span ng-show="myForm.age.$error.pattern" style="color:red">Invalid Age.</span>
</ng-form>
</div>
<script>
var app = angular.module("app", []);
app.controller('myController', ['$scope', function ($scope) {
$scope.regEx = /^[0-9]{1,2}$/;
}]);
</script>
</body>
</html>