0

I need to provide simple array of data with years. What will be right to create: pipe or typically service class?

Iameging, that it is pipe. Then can I iterate this pipe in ngFor like this:

ngFor="item of pipe()"?
1
  • pipe isn't meant for types like that. Pipes are to transform outputvalue of existing array-elements. like that: ngFor="let item of array | uppercase" Commented Aug 17, 2017 at 11:31

1 Answer 1

2

You should create an array in this case, neither pipe nor a service.

You can create an array by calling a function with the name pipe() though, that would return an array with your specified data.

Sign up to request clarification or add additional context in comments.

7 Comments

So, I can use or pipe or service not difference? Can I call pipe name in ngFor?
i meant you should not
I got you, but I don't want to create the same array in each component, therefore. What then?
@OPV, You can move array to the file (e.g. constants.ts) and then import it in each component
@OPV did the answer help?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.