1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How to use datepipe outside of a component.ts in angular?

Discussão em 'Angular' iniciado por WenliL, Setembro 7, 2025.

  1. WenliL

    WenliL Guest

    I have a typescript file used to export some constant variables (export const). I would like to use datepipe to format date in the ts file, but I do not know how to add service to use datepipe in a non component ts file.

    For example:

    export const dateObject = [
    {
    value: {
    start: new Date(),
    end: new Date().setFullYear(new Date().getFullYear() + 10),
    },
    title: 'Ten Years Later'
    }
    ];


    How can I make datepipe.transform(, 'yyyy-MM-dd') work in this typescript?

    Thank you!!

    Continue reading...

Compartilhe esta Página