我正在AngularJs中处理动态生成的字段并对其进行验证,但由于某种原因它无效。
我是棱角分明的新人,有人可以帮助我让它发挥作用吗?
以下是JsFiddle
的链接HTML部分在下面。
最大长度:10 允许:仅限数字 最大长度:4 允许:仅限数字 添加其他联系人JavaScript部分
(function (angular) {
'use strict';
angular.module('app').controller(
'specialConditionsController', [
'$scope', '$log', '$window', '$http', 'SweetAlert',
function (
$scope, $log, $window, $http, SweetAlert
) {
var counterAuthorisedPerson = 0;
var maxContactCountAllowed = 3;
$scope.tetboxContactInformationAuthorisedPersonFullName = [
{
authorisedPersonFullName: 'AuthorizedPersonproviderFullName_' + counterAuthorisedPerson,
providerFullName: '',
authorisedPersonPhone: 'AuthorizedPersonContactPhone_' + counterAuthorisedPerson,
providerPhoneNumber: '',
authorisedPersonPhoneExt: 'AuthorizedPersonContactPhoneExt_' + counterAuthorisedPerson,
providerPhoneExtension: ''
}
];
$scope.addAnotherContactforAuthorisedPerson = function () {
if (counterAuthorisedPerson == maxContactCountAllowed) {
alert("Upto Four contacts are allowed");
return;
} else {
counterAuthorisedPerson++;
$scope.tetboxContactInformationAuthorisedPersonFullName.push({
authorisedPersonFullName: 'AuthorizedPersonproviderFullName_' + counterAuthorisedPerson,
providerFullName: '',
authorisedPersonPhone: 'AuthorizedPersonContactPhone_' + counterAuthorisedPerson,
providerPhoneNumber: '',
authorisedPersonPhoneExt: 'AuthorizedPersonContactPhoneExt_' + counterAuthorisedPerson,
providerPhoneExtension: ''
});
return false;
}
}
}
])
})(angular);