angularjs的新增和非空判斷
阿新 • • 發佈:2019-02-06
//點選新增
$scope.addll = function() {
$scope.isshow = true;
}
//點選儲存把資料提交到原始資料
$scope.id="";
$scope.name="";
$scope.yhm="";
$scope.phone="";
$scope.price="";
$scope.cry="";
$scope.xdsj="";
$scope.zt="";
$scope.chll = function() {
var kai1=true;
var kai2=true;
$scope.valArr=[];
if($scope.yhm==""||$scope.yhm==null){
$scope.valArr.push("使用者名稱不能為空");
kai1=false;
}else{
if($scope.yhm.length<2 || $scope.yhm.length>10){
$scope.valArr.push("使用者名稱長度在2到10");
kai1=false;
}
}
if($scope.cry==null||$scope.cry==""){
$scope.valArr.push("地址不能為空");
kai2=false;
}
if(kai1&kai2){
$scope.datas.push({
id: $scope.id,
name: $scope.name,
yhm: $scope.yhm,
phone: $scope.phone,
price: $scope.price,
cry: $scope.cry,
xdsj: $scope.xdsj,
zt: $scope.zt,
});
}
}
});
$scope.addll = function() {
$scope.isshow = true;
}
//點選儲存把資料提交到原始資料
$scope.id="";
$scope.name="";
$scope.yhm="";
$scope.phone="";
$scope.price="";
$scope.cry="";
$scope.xdsj="";
$scope.zt="";
$scope.chll = function() {
var kai1=true;
var kai2=true;
$scope.valArr=[];
if($scope.yhm==""||$scope.yhm==null){
$scope.valArr.push("使用者名稱不能為空");
kai1=false;
}else{
if($scope.yhm.length<2 || $scope.yhm.length>10){
$scope.valArr.push("使用者名稱長度在2到10");
kai1=false;
}
}
if($scope.cry==null||$scope.cry==""){
$scope.valArr.push("地址不能為空");
kai2=false;
}
if(kai1&kai2){
$scope.datas.push({
id: $scope.id,
name: $scope.name,
yhm: $scope.yhm,
phone: $scope.phone,
price: $scope.price,
cry: $scope.cry,
xdsj: $scope.xdsj,
zt: $scope.zt,
});
}
}
});