【问题标题】:Error: [$injector:nomod] Module 'ui.bootstrap' is not available! You either misspelled [...]错误:[$injector:nomod] 模块 'ui.bootstrap' 不可用!你要么拼错 [...]
【发布时间】:2014-10-28 18:34:22
【问题描述】:

我在这里遇到了这个问题,到目前为止,我还没有得到任何一致的解决方案。我在前端使用 Angular 运行 Java 项目,并尝试使用 ui-bootstrap 实现自动完成功能,但我总是收到此错误。

Uncaught Error: [$injector:modulerr] Failed to instantiate module textChangrApp due to: Error: [$injector:modulerr] Failed to instantiate module ui.bootstrap due to: Error: [$injector:nomod] Module 'ui.bootstrap' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://errors.angularjs.org/1.3.0-rc.4/$injector/nomod?p0=ui.bootstrap
    at http://localhost:8080/bower_components/angular/angular.js:80:12
    at http://localhost:8080/bower_components/angular/angular.js:1787:17
    at ensure (http://localhost:8080/bower_components/angular/angular.js:1711:38)
    at module (http://localhost:8080/bower_components/angular/angular.js:1785:14)
    at http://localhost:8080/bower_components/angular/angular.js:4024:22
    at forEach (http://localhost:8080/bower_components/angular/angular.js:330:20)
    at loadModules (http://localhost:8080/bower_components/angular/angular.js:4008:5)
    at http://localhost:8080/bower_components/angular/angular.js:4025:40
    at forEach (http://localhost:8080/bower_components/angular/angular.js:330:20)
    at loadModules (http://localhost:8080/bower_components/angular/angular.js:4008:5) http://errors.angularjs.org/1.3.0-rc.4/$injector/modulerr?p0=ui.bootstrap&p…2F%2Flocalhost%3A8080%2Fbower_components%2Fangular%2Fangular.js%3A4008%3A5)
    at http://localhost:8080/bower_components/angular/angular.js:80:12
    at http://localhost:8080/bower_components/angular/angular.js:4047:15
    at forEach (http://localhost:8080/bower_components/angular/angular.js:330:20)
    at loadModules (http://localhost:8080/bower_components/angular/angular.js:4008:5)
    at http://localhost:8080/bower_components/angular/angular.js:4025:40
    at forEach (http://localhost:8080/bower_components/angular/angular.js:330:20)
    at loadModules (http://localhost:8080/bower_components/angular/angular.js:4008:5)
    at createInjector (http://localhost:8080/bower_components/angular/angular.js:3948:11)
    at doBootstrap (http://localhost:8080/bower_components/angular/angular.js:1480:20)
    at bootstrap (http://localhost:8080/bower_components/angular/angular.js:1501:12) http://errors.angularjs.org/1.3.0-rc.4/$injector/modulerr?p0=textChangrApp&…F%2Flocalhost%3A8080%2Fbower_components%2Fangular%2Fangular.js%3A1501%3A12) angular.js:80(anonymous function) angular.js:80(anonymous function) angular.js:4047forEach angular.js:330loadModules angular.js:4008createInjector angular.js:3948doBootstrap angular.js:1480bootstrap angular.js:1501angularInit angular.js:1395(anonymous function) angular.js:24904trigger angular.js:2715eventHandler angular.js:2986



//index.html
    <head>
        <!-- ... -->
        <script src="../bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
        <script src="../bower_components/angular/angular.js"></script>
        <script src="../bower_components/angular-aria/angular-aria.js"></script>
        <script src="../bower_components/angular-animate/angular-animate.js"></script>
        <script src="../bower_components/hammerjs/hammer.js"></script>
        <script src="../bower_components/angular-material/angular-material.js"></script>
    </head>
//app.js
    angular
      .module( 'textChangrApp', [ 'ngAnimate', 'ngMaterial','directive.g+signin', 'ui.bootstrap'])

我觉得导入时我的&lt;head&gt; 一定有问题,因为它到目前为止工作正常,现在它崩溃了。希望你能在这方面给我一点帮助。

谢谢。

【问题讨论】:

  • 你需要在 angularjs 之后包含 bootstrap。 &lt;script src="../bower_components/angular/angular.js"&gt;&lt;/script&gt;&lt;script src="../bower_components/angular-bootstrap/ui-bootstrap-tpls.js"&gt;&lt;/script&gt;
  • 没错。像这样简单。我花了更长的时间写它然后等待答案!非常感谢。

标签: angularjs angular-ui-bootstrap bower


【解决方案1】:

您必须在 angularjs 文件之后加载 ui.boostrap 模块。

【讨论】:

    【解决方案2】:

    通过 bower 安装它的另一种方法,这里是说明。

    将以下 2 个包添加到您目录中的 bower.json。

    "bootstrap": "*",
    "angular-bootstrap": "*",
    

    从你的目录运行bower update

    ui.bootstrap 添加到如下的角度模块中。

    将其连接到视图中以使引导程序工作

    CSS

    <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
    

    JS

    <script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
    

    【讨论】:

      【解决方案3】:

      您必须在 angular.min.... 之后包含以下内容。

      <script src="..//ui-bootstrap-custom-tpls-0.12.0.min.js" type="text/javascript"></script>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-23
        • 1970-01-01
        • 2014-12-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多