AngularJS实现存入文本,搜索,敏感字符
来源:互联网 发布:免费网络课程网站 编辑:程序博客网 时间:2024/05/22 03:28
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="angular.js"></script>
<script>
var app = angular.module("myApp",[]);
app.filter("myFilter",function () {
return function (text) {
if (text.indexOf("a")>=0){
alert("敏感字符");
return text.replace(/a/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);
}
}
var flag = true;
$scope.shousuo = function () {
for (record in $scope.records){
if ($scope.records[record] == $scope.selectRecord){
alert("已存在");
flag = false;
}
}
if (flag){
alert("不存在");
}
}
})
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<center>
<h3>记账本</h3>
<div style="width: 300px; height: 250px; border: solid; background-color: beige">
<p ng-repeat="record in records">{{record | myFilter}}</p>
</div>
<br><br>
输入框:<input type="text" ng-model="newRecord"><br><br>
<button ng-click="addRecord()">记录</button>
<br><br>
搜索框:<input type="text" ng-model="selectRecord">
<br><br>
<button ng-click="shousuo()">搜索</button>
</center>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="angular.js"></script>
<script>
var app = angular.module("myApp",[]);
app.filter("myFilter",function () {
return function (text) {
if (text.indexOf("a")>=0){
alert("敏感字符");
return text.replace(/a/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);
}
}
var flag = true;
$scope.shousuo = function () {
for (record in $scope.records){
if ($scope.records[record] == $scope.selectRecord){
alert("已存在");
flag = false;
}
}
if (flag){
alert("不存在");
}
}
})
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<center>
<h3>记账本</h3>
<div style="width: 300px; height: 250px; border: solid; background-color: beige">
<p ng-repeat="record in records">{{record | myFilter}}</p>
</div>
<br><br>
输入框:<input type="text" ng-model="newRecord"><br><br>
<button ng-click="addRecord()">记录</button>
<br><br>
搜索框:<input type="text" ng-model="selectRecord">
<br><br>
<button ng-click="shousuo()">搜索</button>
</center>
</body>
</html>
阅读全文
0 0
- AngularJS实现存入文本,搜索,敏感字符
- AngularJS实现存入文本,搜索文本,敏感字符
- Angularjs敏感字符
- angularjs过滤敏感字符
- angularjs过滤敏感字符
- angularJS实现查询/选择排序/添加/敏感字符过滤
- AngularJS敏感字符过滤代码案例
- AngularJS实现下拉框排序/添加数据/查询数据/敏感字符过滤
- angular的排序,敏感字符,添加,搜索
- 自定义标签实现过滤敏感字符
- angular+记录消息+搜索消息+敏感字符过滤
- angularjs material 实现搜索框
- angularjs实现分页和搜索
- (angularjs) 数据的增查(添加用户,查询名字,实现排序,判断非空 ,是否是数字,是否重名,敏感字符)
- angularjs去敏感词
- angularjs-添加数据,姓名查询,过滤敏感字符,下拉菜单查询
- 文本搜索(C实现)
- angularjs的过滤器实现搜索与排序
- selenium之模态框处理+检测元素是否多层嵌套
- 数据结构实验之串三
- Tornado框架04-配置文件和路由
- 面向对象
- AngularJS实现存入文本,搜索文本,敏感字符
- AngularJS实现存入文本,搜索,敏感字符
- 5位运动员参加了10米台跳水比赛,有人让他们预测比赛结果
- SASS入门介绍及安装
- 欢迎使用CSDN-markdown编辑器
- Algorithms(一)
- Tornado框架05-输入和输出,接口调用顺序
- 如何让别人远程连接到自己的SQL server数据库
- PHP-FPM进程池探秘
- BZOJ 2658 [Zjoi2012]小蓝的好友(mrx)