I'm a little confused about when to use a service, versus when to export functions or classes.
Here's what I mean by exporting a class: See the top answer here Angular 2: Functions to be used across all components
export class Utils {
public static log(msg:string){
console.log(msg);
}
}
Which is imported here and used
import {Utils} from './utils'
class parent{
foo(s: string){
Utils.log(s);
}
}
class child{
constructor(){
Utils.log("Hello");
}
}
And here's what I mean by exporting functions in place of a service:
export printAll(toPrint:string): void{
}
as seen in this question
What's the difference between these approaches in comparison to using a service? What's the difference between these two methods? Pros, cons? Thought process when deciding which to use?