angularJS 특수 문자 필터링

5981 단어 angularJS
/span>html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Titletitle>
    <script src="ajs/angular.min.js">script>
    <script>
        var app=angular.module("myapp",[]);
        app.filter("val1",function () {
            return function (val,flag) {
                return val.replace(/ | /g,flag);
            }
        });
        app.filter("val2",function () {
            return function (val) {
                return val.replace(/ | /g,function (word) {
                    var count="";
                    for(var i=0;ii++){
                        count+="#";
                    }
                    return count;
                })
            }
        })
        app.controller("crty",function ($scope) {
            $scope.val="";
        })
    script>
head>
<body>
<DIV ng-app="myapp" ng-controller="crty">
<input type="text" ng-model="val">
    <p>{{val|val1:"*"}}p>
    <p>{{val|val2}}p>
DIV>
body>
html>

좋은 웹페이지 즐겨찾기