How to pass filter to a directive in AngularJS

前端 未结 2 383
走了就别回头了
走了就别回头了 2021-01-22 05:11

I have a custom directive and I want to be able to pass a filter name to it. That filter will then be use in my template. Here is what I got so far:

the directive:

2条回答
  •  终归单人心
    2021-01-22 05:31

    You don't need to have access to it in the controller to use it in the View. That's kind of the point of filters. If you actually needed it in the controller, you could request it by itself by asking for filterTempFilter to be injected. Or you can have the $filter provider injected and ask for your specific filter from it.

提交回复
热议问题