0

So, I have a function in main.ts

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

import * as $ from 'jquery'

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule)
  .catch(err => console.log(err));

export function view_user(id) {
  ...some jQuery stuff
}

I use this function inside a component like this:

import { view_user } from 'src/main';
...
show_user(id){
    view_user(id)
}

and I am getting this warning:

Circular dependency detected: src/app/profile/profile.component.ts -> src/main.ts -> src/app/app.module.ts -> src/app/app-routing.module.ts -> src/app/profile/profile.component.ts

Iraklis
  • 208
  • 1
  • 5
  • 16
  • 2
    Yes, Angular checks circular dependencies which are a sign of a code smell. Put view_user as a static method in a service class I'd say. – Gimby Nov 22 '18 at 12:43
  • good idea :p i'll try that later :) thanks! – Iraklis Nov 22 '18 at 12:46
  • you can also choose to suppress the warning : Have a look here https://stackoverflow.com/a/51728842/2435263 – dream88 Nov 22 '18 at 13:52

0 Answers0