仅数字输入文本字段在angularjs中不起作用

仅数字输入文本字段在angularjs中不起作用,angularjs,Angularjs,对于pincode/zipcode,仅数字输入不能在angularjs中工作。我在jsp页面和控制器中使用了ng模式,如下所示: app.controller("numOnlyRegex",function($scope) { $scope.numOnlyRegex = /^\d+$/; }); Jsp页面: Pin:<input type="text" class="form-control input-sm" ng-pattern="numOnlyRegex" name="p

对于pincode/zipcode,仅数字输入不能在angularjs中工作。我在jsp页面和控制器中使用了ng模式,如下所示:

app.controller("numOnlyRegex",function($scope)
{
   $scope.numOnlyRegex = /^\d+$/; 
});
Jsp页面:

Pin:<input type="text" class="form-control input-sm" ng-pattern="numOnlyRegex" name="pin" required placeholder="Pin"/><br/>
控制器:

app.controller("numOnlyRegex",function($scope)
{
   $scope.numOnlyRegex = /^\d+$/; 
});
js的scr文件夹是:

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="${pageContext.request.contextPath}/myAppRegistrationModule.js"></script>
<script src="${pageContext.request.contextPath}/numOnlyRegex.js"></script>


你的模块减速是否在numOnlyRegex.js中可用,如果是这样,你必须像这样做:angular.module('myApp').controller('your js name',function(){});不是以你指定的方式above@Hurix好的,让我试试你说的方式:
angular.module('myApp',[]).controller(“numOnlyRegex”,function($scope){$scope.numOnlyRegex=/^\d+$/;})当我将js文件移动到jsp所在的位置时,它在提交时不接受任何值。我的意思是,我在url浏览器的文本框中看不到任何提交的值。这是问题吗?请检查js文件是否已加载到浏览器中。你能为同样的东西创建一个plunkr链接吗?你能进一步调试吗。用于验证的plnkr链路示例