I would like to make a generic module that has a bunch of utility methods, including moment and lodash functionality. I've imported lodash and typed it and I can access it from my components as long as I include the code:
import * as _ from "lodash";
However, I'd like to make this more generic so I can just import my Utils module and have both lodash and moment (as well as a few custom functions) available without having to import these individually in every component.
I've got the following code:
import { Injectable, NgModule } from "@angular/core";
import * as _ from "lodash";
import * as _ from "moment";
@Injectable()
@NgModule({
exports: [_, moment]
})
export class Utils { }
}
I get the following error:
Build:Argument of type '{ exports: LoDashStatic[] 1>; }'
is not assignable to parameter of type 'NgModule'
Edit: What I'd like to do is this:
import { _, moment } from "./Utils.module";
instead of
import * as _ from "lodash";
import * as moment from "moment";
How can I accomplish this?
Edit: Made the code reflect more of what I'd like to accomplish...
@Injectableand@NgModule? Also, lodash is a library and it is not a module