0

I am trying to migrate a static site made with bootstrap to angular using ui-bootstrap which is turning out to fight me every step of the way, so I need someone who has maybe worked with ui-bootstrap before to point me in the right direction. I'm still somewhat new to Angular, but I'm completely new to bootstrap and ui-bootstrap I usually just try to roll my own CSS.

Here is the working static bootstrap html with some irrelevant details removed:

<div class="top-bar">
        <div class="container">
            <div class="row">
                <div class="col-sm-6 hidden-sm-down">
                    <ul class="list-inline">
                        <li class="list-inline-item"><a href="javascript:void(0)"><i class="ion-ios-telephone"></i>Location 1: 1.111.111.1111</a></li>
                        <li class="list-inline-item"><a href="javascript:void(0)"><i class="ion-ios-telephone"></i>Location 2: 1.111.111.1111</a></li>
                    </ul>
                </div>
                <div class="col-sm-6 text-right">
                    <ul class="list-inline">
                        <li class="loc list-inline-item">
                           <a href="#" data-toggle="dropdown" class="dropdown-toggle">Get Directions</i></a>
                            <ul class="dropdown-menu loc-dropdown">
                                <li><a href="https://www.google.com/maps" target="_blank"><i class="ion-android-car flag"></i> Location 1</a></li>
                                <li><a href="https://www.google.com/maps"><i class="ion-android-car flag" ></i> Location 2</a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

When I was first having this trouble I found this thread:

Angularjs bootstrap dropdown not working

so I tried the first solution which obviously did not work, and here is what I have trying to apply the second updated fix:

<div class="top-bar">
        <div class="container">
            <div class="row">
                <div class="col-sm-6 hidden-sm-down">
                    <ul class="list-inline">
                        <li class="list-inline-item"><a href="javascript:void(0)"><i class="ion-ios-telephone"></i>Location 1: 1.111.111.1111</a></li>
                        <li class="list-inline-item"><a href="javascript:void(0)"><i class="ion-ios-telephone"></i>Location 2: 1.111.111.1111</a></li>
                    </ul>
                </div>
                <div class="col-sm-6 text-right">
                    <ul class="list-inline">
                        <li uib-dropdown class="loc list-inline-item">
                           <a uib-dropdown-toggle class="dropdown-toggle">Get Directions</i></a>
                            <ul uib-dropdown-menu class="dropdown-menu loc-dropdown">
                                <li><a href="https://www.google.com/maps" target="_blank"><i class="ion-android-car flag"></i> Location 1</a></li>
                                <li><a href="https://www.google.com/maps"><i class="ion-android-car flag" ></i> Location 2</a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

And nothing is happening, no errors no anything. I don't even get a cursor:pointer, even though I added

.nav, .pagination, .carousel, .panel-title a { cursor: pointer; }

To the top of my css like ui-bootstrap says to.

I tried downloading ui-bootstrap instead of using the cdn and it made no difference. Originally this was all in the template of a nav directive I was building and I thought this might have been causing problems but I moved everything to the home state and I'm having the same problems. I tried moving everything in the dropdown directive controller in the home state controller and nothing happened. I also tried to copy and paste the dropdown example plunker html and js into my project and still had the same results..

Things that may be of note:

I'm using gulp to bundle my js and custom css, neither of which have anything applied to this snippet though.

I'm using a nodemon to serve this up on localhost

I'm using these CDNs for CSS:

<!-- Normalize -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css" />
    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" />

and these for JS:

<!-- angular -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.js"></script>
<!-- angular animate -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-animate.js"></script>
<!-- angular sanitize -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-sanitize.js"></script>
<!-- angular ui-router -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/1.0.3/angular-ui-router.min.js"></script>
<!-- angular ui-bootstrap -->
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.5.0.js"></script>

I'm just at a loss here, I must be missing something that's right under my nose that I can't see.

  • works for me, did you include the module `'ui.bootstrap'` ? – svarog May 31 '17 at 07:58
  • Thank you for the response and trying it. Yes my app.js starts with this: `angular.module('app', ['ui.router','ui.bootstrap', 'ngAnimate', 'ngSanitize'])` –  May 31 '17 at 19:45
  • just noticed you're using bootstrap 4 alpha, can you revert to 3.3.7 and try again ? also, are you sure all your css files are properly linked ? – svarog May 31 '17 at 20:23
  • 1
    That worked! After reading your comment I noticed [here](https://angular-ui.github.io/bootstrap/) it specifically says `Bootstrap CSS (tested with version 3.3.7). This version of the library (2.5.0) works only with Bootstrap CSS in version 3.x. 0.8.0 is the last version of this library that supports Bootstrap CSS in version 2.3.x.` Are you aware of a version that works with bootstrap4? There are elements of it I'm using. Again, thank you for taking the time to help me. –  May 31 '17 at 20:55
  • i know ng-bootstrap works with version 4, but it's for angular 2+ – svarog May 31 '17 at 21:12
  • Darn, guess I'll try to learn Angular2, this project will take longer than I thought. If you want to submit an answer I'll mark it as solved since you solved my problem. Thanks again I appreciate it. –  May 31 '17 at 21:54

0 Answers0