angular的排序,敏感字符,添加,搜索

1.这是用angularjs'所做的样式,排序是经过他的字的开头字母进行排序是可以用在表格中的
2.而敏感字符是一种禁用的词语,让人在打字的过程中不会让其输入敏感的文字





<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="日考14/angular.js"></script>
    <script>
        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.records = ["早上花了5块钱吃早饭","中午花了20块钱吃早饭"];
            $scope.jilu = function () {
                if ($scope.tianjia == "" || $scope.tianjia == null){
                    alert("输入的内容不能为空?");
                }else{
                    $scope.records.unshift($scope.tianjia);
                    alert($scope.records[2]);
                }

            };
            var flag = true;
            $scope.sousuo = function () {
                for (record in $scope.records){
                    if ($scope.records[record] == $scope.chazhao){
                        $scope.show = true;
                        $scope.title = "存在";
                        $scope.bth = "确定";
                    }else {
                        $scope.show = true;
                        $scope.title = "不存在";
                        $scope.bth = "确定";
                    }
                }
            }
            $scope.hide = function () {
                $scope.show = false;
            }
        })
    </script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
    <center>
        记账本
        <div style="width: 300px;height:200px;background-color: red;border: 2px solid blue">
            <p ng-repeat="record in records">{{record | myFilter}}</p>
        </div>
        <br><br>
        输入框:<input type="text" placeholder="输入信息" ng-model="tianjia"><br><br>
        <button ng-click="jilu()">记录</button><br><br>
        搜索框:<input type="text" placeholder="搜索信息" ng-model="chazhao"><br><br>
        <button ng-click="sousuo()">搜索</button>

        <div ng-show="show" style="width: 300px; height: 200px;border: 1px solid #000;background: #eee;text-align: center;position: absolute; top: 50%;left: 50%;margin-left: -150px; margin-top: -100px;">
            <p>提示</p>
            <p>{{title}}</p>
            <button ng-click="hide()">{{bth}}</button>
        </div>
    </center>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值