在我的应用程序,我创建一个对象是这样的:显示一个div,如果文本框为空(NG-重复)
$scope.editphonenumbers = [];
在NG单击,按下一个目标是这样的:
$scope.addEditPhone = function(){
var person = {
phoneno: "",
name : ""
};
if($scope.editphonenumbers.length<3){
$scope.editphonenumbers.push(person);
}
};
该电话号码将在NG-重复显示:
<div class="relativeWrap" ng-repeat="phone in editphonenumbers">
<input placeholder="Phone Number" pattern="[0-9]{10}" ng-maxlength="10" maxlength="10" type="text" name="phonenumber[]" ng-model="phone.phoneno" >
</div>
现在我需要显示一个div如果文本框的任何一个是空的。
我试过如下:
<div ng-show="checkPhoneSS();">Phone Number is Mandatory</div>
$scope.checkPhoneSS=function(){
angular.forEach($scope.editphonenumbers, function(item) {
if(item.phoneno==""){
return true;
}
});
return false;
};
但这种方法烧制很多次,显示出比实际数据更个性化。
它的工作...谢谢 – ramesh