Suppress “Circular dependency detected” suppress warning in Angular 6

后端 未结 3 2026
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-11 15:11

I get the warning

Circular dependency detected!

in Angular 6 and I know why this problem appears, but it is not a problem at all

3条回答
  •  北海茫月
    2021-01-11 15:52

    It should be a problem, because it's like a recursive function with multiple components/modules. Ignoring the warning may cause a slow site, memory leaks, etc.

    You may not notice anything at the moment, but it's bad practice, that you shouldn't get used to.

    Here is an example, how your circular dependency could be resolved.

    Edit:

    If you want to disable the warning completely, you can do that by modifying your angular.json config file.

    "defaults": {
        "apps": {
          "showCircularDependencies": false
        }
        "build": {
          "showCircularDependencies": false
        }
      }
    

提交回复
热议问题