user26776
user26776

Reputation: 131

Angular 2 - Add file with Functions

How do I add a file only with functions that i will use several times in the angular js 2 ?

The created file has to be in ts or may be in js?

Upvotes: 0

Views: 46

Answers (1)

agsolid
agsolid

Reputation: 1298

You should create a service class and inject it into the components that will use it's functions.

Angular has a great tutorial on implementing services:

Angular Service Tutorial

Upvotes: 1

Related Questions