Angular - Use pipes in services and components

前端 未结 8 1546
南笙
南笙 2020-11-22 09:42

In AngularJS, I am able to use filters (pipes) inside of services and controllers using syntax similar to this:

$filter(\'date\')(myDate, \'yyyy-MM-dd\');
         


        
8条回答
  •  余生分开走
    2020-11-22 10:12

    If you want to use your custom pipe in your components, you can add

    @Injectable({
      providedIn: 'root'
    })
    

    annotation to your custom pipe. Then, you can use it as a service

提交回复
热议问题