在我的應用程序,我創建一個對象是這樣的:顯示一個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