简体   繁体   English

将Bootstrap UI模块添加到angularjs项目

[英]Adding Bootstrap UI Module to angularjs project

I'm trying to add the bootstrap-ui module to my angular.js project. 我正在尝试将bootstrap-ui模块添加到我的angular.js项目中。 The documentation states that I simply have to add 文档指出,我只需要添加

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

to get this working. 使它工作。 But I can't find out how I would add this in any way. 但是我不知道如何以任何方式添加它。 I've read the whole chapter of https://docs.angularjs.org/guide/module and read lots of threads about it, but everything I tested didn't work so far. 我已经阅读了https://docs.angularjs.org/guide/module的整个章节,并阅读了很多有关它的线程,但是到目前为止,我测试的所有内容都无法正常工作。

my app.js : 我的app.js

angular.module('MyApp', ['ngCookies', 'ngResource', 'ngMessages', 'ngRoute', 'mgcrea.ngStrap'])
.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
    $locationProvider.html5Mode(true);
// followed by my routing

myCtrl myCtrl

angular.module('MyApp')
    .controller('MyCtrl', ['$scope', '$location', '$rootScope', '$routeParams', '$resource', '$alert', 'MyService',
        function ($scope, $location, $rootScope, $routeParams, $resource, $alert, MyService) {

what I tried: 我试过的

  • adding 'ui.bootstrap' after 'mgcrea.ngStrap' in app.js app.js“mgcrea.ngStrap”之后增加“ui.bootstrap”
  • adding 'ui.bootstrap' after *'MyService' in myCtrl myCtrl加入* '为MyService'后'ui.bootstrap'
  • many more similar variations 还有更多类似的变化

The error messages I get depend on what I did. 我收到的错误消息取决于我所做的事情。 Since I'm probably completely on the wrong path at the moment I was hoping someone could tell me how I can add a module in angular.js correctly? 由于目前我可能完全走在错误的道路上,所以我希望有人可以告诉我如何正确地在angular.js中添加模块?

edit some error messages I encountered: 编辑我遇到的一些错误消息:

When I start my Crtl code with: 当我使用以下代码启动Crtl代码时:

angular.module('MyApp', ['ui.bootstrap'])

I get 我懂了

[ng:areq] Argument 'NavbarCtrl' is not a function, got undefined

(navbarctrl is a completely different ctrl) (navbarctrl是完全不同的ctrl)

when I start my app.js with 当我启动我的app.js

angular.module('MyApp', ['ngCookies', 'ngResource', 'ngMessages', 'ngRoute', 'mgcrea.ngStrap', 'ui.bootstrap'])

I get 我懂了

TypeError: object is not a function

In my AuthService I try to use $alert (this works without bootstrap-ui) like 在我的AuthService我尝试使用$ alert(在没有bootstrap-ui的情况下有效)

$alert({
    title: 'Success!', //...

**edit 2: ** the problem seems to be that I can only use ngStrp OR ui.bootstrap (both use bootstrap underneath) **编辑2:**问题似乎是我只能使用ngStrp或ui.bootstrap(两者都在下面使用bootstrap)

Are you ensuring that Angular UI specific JS Files are sent from server to client through bundling or direct reference? 您是否确保通过捆绑或直接引用将特定于Angular UI的JS文件从服务器发送到客户端?

You have to inject dependency of module in your app: something like this angular.module('MyApp', ['ui.bootstrap']); 您必须在应用程序中注入模块的依赖关系:类似于angular.module('MyApp',['ui.bootstrap']));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM