This article mainly introduces to you in detail the small functions of angluarjs to filter and replace keywords. It has certain reference value. Interested friends can refer to it. I hope it can help everyone.
html style
<body ng-app="myapp" ng-controller="myCtrl"> <input type="text" ng-model="keytext"> <p>{{ keytext|wordFilter:"#" }}</p> </body>
//Customize the filter and replace the keyword
<script> var myapp=angular.module("myapp",[]); /*自定义过滤器*/ myapp.filter("wordFilter",function () { return function (msg,flag) { /*替换关键字*/ return msg.replace(/枪|子弹/g,flag); } }) myapp.controller("myCtrl",function ($scope) { $scope.keytext=""; }) </script>
The effect is as follows:
Related recommendations:
Angularjs filter completes the sorting function example detailed explanation
How to use jQuery sub-element filter selector
Angular search filter batch delete some function summary
The above is the detailed content of angluarjs filter and replace keyword function implementation code. For more information, please follow other related articles on the PHP Chinese website!