angularjs error SCRIPT5022 ng:btstrpd (IE)

本文深入探讨了AngularJS中遇到的常见错误AppAlreadyBootstrapped及其产生的原因,特别是当在同一页面上多次加载AngularJS库导致的应用初始化冲突。文章详细解释了如何通过合理使用`ng-app`和`angular.bootstrap`来避免此类问题,同时提供了实例演示错误的出现方式及解决策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.  https://docs.angularjs.org/error/ng/btstrpd
Error: ng:btstrpd
App Already Bootstrapped with this Element
App Already Bootstrapped with this Element '{0}'
Description

Occurs when calling angular.bootstrap on an element that has already been bootstrapped.

This usually happens when you accidentally use both ng-app and angular.bootstrap to bootstrap an application.

<html>  ...  <body   ng-app = "myApp" >   <script>  angular . bootstrap ( document . body ,   [ 'myApp' ]);   </script>   </body>   </html>

Note that for bootstrapping purposes, the <html> element is the same as document, so the following will also throw an error.

<html>  ...  <script>  angular . bootstrap ( document ,   [ 'myApp' ]);   </script>   </html>

You can also get this error if you accidentally load AngularJS itself more than once.

<html   ng-app >   <head>   <script   src = "angular.js" ></script>  ...  </head>   <body>  ...  <script   src = "angular.js" ></script>   </body>   </html>

2.  根据 这个话。
     

angular.element(document).ready 这句话在IE下 会执行两次~ 所以才会报 error SCRIPT5022 ng:btstrpd  错。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值