标签:r.js doctype $scope alert *** ext inpu contains app
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="angular.js"></script>
<script type="text/javascript">
var app = angular.module("myApp", []);
app.filter("replace", function() {
return function(text) {
//alert(text.indexOf("qq"));
//return text+text.contains("qq");
function replaceValue(text) {
var value = "";
if(text.indexOf("qq")>=0) {
//alert("111");
value = text.replace(/qq/g, "***");
if(value.indexOf("枪")>=0){
return value.replace(/枪/g, "*");
}else{
return value;
}
}else if(text.indexOf("枪")>=0){
value = text.replace(/枪/g, "*");
if(value.indexOf("枪")>=0){
return value.replace(/枪/g, "*");
}else{
return value;
}
}else{
if(value.indexOf("枪")>=0){
return text.replace(/枪/g, "*");
}else{
return text;
}
}
}
return replaceValue(text);
//return text.replace(/qq|枪 /g, "***");
}
});
app.controller("myCtrl", function($scope) {
$scope.value = "qq";
})
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
请输入:<input ng-model="value" />
<p>{{value | replace}}</p>
</body>
</html>
标签:r.js doctype $scope alert *** ext inpu contains app
原文地址:http://www.cnblogs.com/qq402792989/p/7673915.html