如何防止错误:[ng:btstrpd]应用程序已经使用此元素'文档'

时间:2015-06-13 19:20:36

标签: angularjs meteor angular-meteor

使用角度流星v 0.9

尝试正确加载预先打包的AngularMeteor-SmartAdmin示例应用

获取错误:

Error: [ng:btstrpd] App Already Bootstrapped with this Element 'document'

有没有办法弄清楚这个错误发生的原因和位置?

这是我的流星列表:

angular:angular-animate                               1.4.0  AngularJS (official) release. For full...
angular:angular-cookies                               1.4.0  AngularJS (official) release. For full...
angular:angular-resource                              1.4.0  AngularJS (official) release. For full...
angular:angular-route                                 1.4.0  AngularJS (official) release. For full...
angular:angular-sanitize                              1.4.0  AngularJS (official) release. For full...
angularui:angular-ui-router                           0.2.15  angular-ui-router (official): Flexibl...
angularui:ui-utils                                    0.2.4  Angular-ui-utils package for meteor.
autopublish                                           1.0.3  Publish the entire database to all cli...
cfs:http-methods                                      0.0.29  Adds HTTP.methods RESTful
gsklee:ngstorage                                      0.3.0  ngStorage package for Meteor
http                                                  1.1.0  Make HTTP calls to remote servers
insecure                                              1.0.3  Allow all database writes by default
less                                                  1.0.14  The dynamic stylesheet language
meteor-platform                                       1.2.2  Include a standard set of Meteor packa...
planettraining:angular-translate                      2.7.0  Angular Translate
planettraining:angular-translate-loader-static-files  2.7.0  Angular Translate
planettraining:angular-translate-loader-url           2.7.0  Angular Translate
planettraining:angular-translate-storage-cookie       2.7.0  Angular Translate
planettraining:angular-translate-storage-local        2.7.0  Angular Translate
selchenkov:angular-bootstrap-ui                       0.0.1  Meteor 
urigo:angular             0.9.0  

2 个答案:

答案 0 :(得分:7)

问题是index.ng.html中的index.html的文件路径&n; ng-include

应该是

<div ng-include="'client/index.ng.html'">
</div>

路径始终是绝对的,如Angular Meteor教程

中所述
  

值得注意的是 - 路径总是绝对的,而不是相对的!所以,如果&#39; index.ng.html&#39;在客户端文件夹中,您必须放置路径应用程序的整个路径,不管您从哪里调用该文件。   像这样(例如,如果index.ng.html在&#39;客户端&#39;文件夹中):

      <div ng-include="'client/index.ng.html'"></div>

答案 1 :(得分:0)

这仅仅是因为您不恰当地称呼您的身体或div。尝试<div ng-app="app1" ng-controller="controller1">/*code or UI here*/</div>。让第二个调整器<div id="app" ng-app="app2" ng-controller="controller2">/*code or UI here*/</div>进入其中。所以现在你可以打电话 angular.element(document).ready(function () { var appID = document.getElementById('app'); angular.bootstrap(appID, ['app2']); });

避免在两个角度控制器之间发生冲突。因此这两个控制器都是原子的,因此仅在一页中使用。