<! DOCTYPE html>
<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 ("Gun") >=0) {
return Value.replace (/gun/g, "*");
}else{
return value;
}
}else if (Text.indexof ("Gun") >=0) {
Value = text.replace (/gun/g, "*");
if (Value.indexof ("Gun") >=0) {
return Value.replace (/gun/g, "*");
}else{
return value;
}
}else{
if (Value.indexof ("Gun") >=0) {
return Text.replace (/gun/g, "*");
}else{
return text;
}
}
}
return Replacevalue (text);
Return Text.replace (/qq| gun/g, "* * *");
}
});
App.controller ("Myctrl", function ($scope) {
$scope. Value = "QQ";
})
</script>
<body ng-app= "myApp" ng-controller= "Myctrl" >
Please enter: <input ng-model= "value"/>
<p>{{value | replace}}</p>
</body>
HTML Angular to replace keywords