angularjs记事本

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript" src="../AngularJS/angular.js" ></script>
		<script>
			var haha = 3;
			var app = angular.module("myApp",[]);
			//自定义过滤器
			app.filter("myFilter",function(){
				return function(text){
					//alert("fasd");
					if(text.indexOf("敏感字符")>=0){
						//alert("asdfasdf");
						alert("包含敏感字符")
						return text.replace(/敏感字符/g,"***");
					}
					return text;
				}
			});
			app.controller("myCtrl",function($scope){
				$scope.newRecord = "";
				$scope.selectRecord = "";
				$scope.records = ["早上花了5块钱吃早饭","中午花了20块钱吃早饭"];
				$scope.addRecord = function(){
					if($scope.newRecord == "" || $scope.newRecord == null){
						 alert("输入内容为空");
					}else{
						$scope.records.unshift($scope.newRecord);
						
						alert($scope.records[2]);
					}
				};
				var flag = true;
				$scope.selectRecordMethod = function(){
					for(record in $scope.records){
						if($scope.records[record] == $scope.selectRecord){
							alert("已经存在");
							flag = false;
						}
					}
					if(flag){
						alert("不存在");
					}
				}
				/*$scope.myFilter = function(text){
					var reg = /敏感字符/;
					if(reg.test(text)){
						return text.replace(/敏感字符/g,"***");
					}
				}*/
			});
		</script>
	</head>
	<body ng-app="myApp" ng-controller="myCtrl">
		<center>
			记事本
			<div style="width: 300px; height: 250px; border: 1 solid blue; background-color:#A6E1EC;">
				<p ng-repeat="record in records ">{{record | myFilter }}</p>
			</div><br/>
			输入框:<input type="text" ng-model="newRecord" />
			<button ng-click="addRecord()">记录</button><br/>
			搜索:<input type="text" ng-model="selectRecord" />
			<button ng-click="selectRecordMethod()">记录</button>
		</center>
	</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值