Currently, I have a service that is responsible for loading a list of modules:
@Injectable()
export class MyService {
public allowedModules: any = this.modulesFilter();
constructor() {
}
public modulesFilter() {
const testPef = true;
const modulesList= [];
if (testPef === true) {
modulesList.push(MyFirstModule);
} else {
modulesList.push(MySecondModule);
}
return modulesList;
}
}
Now, in my module file, I attempted to use it like this:
@NgModule({
imports: [
CommonModule,
MyService.allowedModules // THIS IS WRONG
],
declarations: [],
providers: [
MyService
],
exports: [
]
})
export class MyModule { }
I acknowledge that accessing the service directly within the module is incorrect.
Any recommendations on how to proceed?