//點擊保存按鈕
$scope.save = function(){
var i = $scope.datas.length;+1
$scope.tips = false;//控制錯誤信息是否顯示
$scope.cw = [];//放錯誤信息的數組
if($scope.name == undefined ||$scope.name == null){
$scope.cw.push("姓名不能爲空");
alert("姓名不能爲空");
return;
}
if(!/^\d+$/.test($scope.age)){
$scope.cw.push("年齡格式錯誤");
alert("年齡格式錯誤");
return;
}
if($scope.cw.length>0){
$scope.tips = true;
}else{
var data2 = {
id:i++,
name:$scope.name,
age:$scope.age,
pinyin:$scope.pinyin,
job:$scope.job,
system:"刪除"
};
$scope.datas.push(data2);//把數組放入原始數組中
$scope.isShow = false;//讓添加頁不顯示
}
//查詢按鈕
$scope.sel = function(){
if($scope.selName == null){//如果爲空提示
alert("不能爲空");
}else{
if($scope.selName.match("王")){
alert("有敏感詞彙");
}else{
var filter = $filter("filter");
var shu = filter($scope.datas,{name:$scope.selName});
if(shu.length == 0){
alert("未找到內容");
}else{
$scope.datas = shu;
}
}
}
}