未知提供程序错误。如何在 angularjs 上添加 angular-bootsrap

Unknown provider error. how to add angular-bootsrap on angularjs

yo angular
bower install angular-bootstrap --save

在 app.js 中添加了 'ui.bootstrap'。 添加了

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

在index.html。 检查 bower.json 它有 'angular-bootstrap'.

现在我得到了

Uncaught Error: [$injector:unpr] Unknown provider: $$qProvider <- $$q <- $animate <- $compile

这是我的全部代码 [app/scripts/app.js]

'use strict';

/**
 * @ngdoc overview
 * @name radio2App
 * @description
 * # radio2App
 *
 * Main module of the application.
 */
angular
  .module('radio2App', [
    'ngAnimate',
    'ngCookies',
    'ngRoute',
    'ui.bootstrap'
  ])
  .config(function ($routeProvider) {
    $routeProvider
      .when('/', {
        templateUrl: 'views/main.html',
        controller: 'MainCtrl'
      })
      .when('/about', {
        templateUrl: 'views/about.html',
        controller: 'AboutCtrl'
      })
      .otherwise({
        redirectTo: '/'
      });
  });

[app/scripts/main.js]

'use strict';

/**
 * @ngdoc function
 * @name radio2App.controller:MainCtrl
 * @description
 * # MainCtrl
 * Controller of the radio2App
 */
angular.module('radio2App')
  .controller('MainCtrl', function ($scope) {
    $scope.awesomeThings = [
      'HTML5 Boilerplate',
      'AngularJS',
      'Karma'
    ];
  });

[bower.json]

{
  "name": "radio2",
  "version": "0.0.0",
  "dependencies": {
    "angular": "^1.3.0",
    "json3": "^3.3.0",
    "es5-shim": "^4.0.0",
    "angular-animate": "^1.3.0",
    "angular-cookies": "^1.3.0",
    "angular-route": "^1.3.0",
    "angular-bootstrap": "~0.12.0"
  },
  "devDependencies": {
    "angular-mocks": "~1.3.0",
    "angular-scenario": "~1.3.0"
  },
  "appPath": "app"
}

[app/index.html]

.....
    <!-- build:js(.) scripts/vendor.js -->
    <!-- bower:js -->
    <script src="bower_components/angular/angular.js"></script>
    <script src="bower_components/angular-animate/angular-animate.js"></script>
    <script src="bower_components/angular-cookies/angular-cookies.js"></script>
    <script src="bower_components/angular-route/angular-route.js"></script>
    <script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
    <!-- endbower -->
    <!-- endbuild -->
.....

大部分代码都是由你的脚手架工具制作的。我只添加了几行,就像我提到的那样。

angular.module('myModule', ['ui.bootstrap']);

你应该像上面的代码一样在你的模块配置中包含BootStrap依赖,当你使用BootStrap

时有必要添加