0
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: '/'
      });
  });

[应用程序/脚本/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'
    ];
  });

[凉亭.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"
}

[应用程序/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 -->
.....

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

4

1 回答 1

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

您应该像上面的代码一样在您的模块配置中包含BootStrap 依赖项,当您使用 BootStrap 时需要添加

于 2015-01-11T16:16:46.010 回答