angular.js - 当ui-view放在body元素上,为什么会导致angular重复启动
阿神
阿神 2017-05-15 17:05:40
0
1
468

用Angualr开发一个单页应用,路由使用了ui-router。

当我将ui-view放在body标签上时,出现了以下报错信息:

当我将ui-view作为标签<ui-view></ui-view>单独放置时,这个错误就不会出现了,请问是什么原因?

阿神
阿神

闭关修行中......

reply all(1)
世界只因有你

Did you also put ngApp on the body?
ngApp automatically starts angular. If the view is started multiple times, it will report the error displayed to you. You will understand if you look at the source code of angular

if (window.angular.bootstrap) {
  //AngularJS is already loaded, so we can return here...
  if (window.console) {
    console.log('WARNING: Tried to load angular more than once.');
  }
  return;
}

By the way, I tested it myself by placing ui-view on the body and no error was reported. The premise is that I placed ngApp on the html

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template