WARNING: Tried to load angular more than once. Angular JS

后端 未结 23 1489
有刺的猬
有刺的猬 2020-12-01 13:57

I am trying to view my app after running Grunt Build. I use grunt serve:dist to see all production ready build but in the browser I get an infinite loop saying:

23条回答
  •  情话喂你
    2020-12-01 14:19

    In my case, angular library and my angular module code is dynamically loaded inside another application which I dont have any control. And these are loaded on click of of a button. For the first time its working fine but when user clicks 2nd time the library and other files loads again and it gives me the warning.

    WARNING: Tried to load angular more than once.

    var isInitialized = element.injector();
    if (!isInitialized) {
      angular.bootstrap(angular.element(document.getElementById('#mainDiv')), ['defaultApp']);
    }
    

提交回复
热议问题