-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
过滤器 #9
Comments
自定义过滤器,根据输入的关键词,全文搜索,如果有对应的结果那就让它变成红色背景
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
自定义过滤器
我们可以使用filter函数自定义一个过滤器,filter函数的第一个参数是过滤器到时候再DOM中要使用的名字,第二个参数是定义一个执行过滤操作的函数,返回的要是一个函数
我们就可以在DOM中使用这个过滤器,这里执行的时候会输出text的值,过滤器中的返回函数第一个参数就是我们传进去的text值,第二个参数是传递一个值,可以是布尔值,字符串,数字等等
<p>{{text|wsscat}}</p>
<p>{{text|wsscat:true}}</p>
所以打印的结果为
在控制器中使用过滤器服务
往控制器中注入$filter服务
$filter(过滤器名字)(需要被过滤的参数,过滤器设置的参数)
The text was updated successfully, but these errors were encountered: