Reputation: 3476
I'm using the angular-bootstrap-datetimepicker, specifically the "Drop-down Datetime with input box". It makes use of the data-toggle="dropdown"
attribute. The calendar appeared when I had my AngularJS App running on a simple nodejs express server. Since I migrated to yeoman, clicking on the dropdown activates a redirect to /#
(http://localhost:9000/#
)
This is how I'm using the datetimepicker in the view:
dtpform.html
<div class="dropdown">
<a class="dropdown-toggle" id="dropdown2" role="button" data-toggle="dropdown" data-target="#" href="#">
<div class="input-group"><input type="text" class="form-control" data-ng-model="startDate"><span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<datetimepicker data-ng-model="startDate" data-datetimepicker-config="{ dropdownSelector: '#dropdown2', minView: 'hour' }"/>
</ul>
</div>
Other people that had the same problem forgot some dependencies. Mine seem to be all set. If I insert the datetimepicker into the index.html instead of the /dtp route, it Pops Up.
index.html
...
<!-- build:js(.) scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.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-resource/angular-resource.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-touch/angular-touch.js"></script>
<script src="bower_components/moment/moment.js"></script>
<script src="bower_components/angular-moment/angular-moment.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/angular-bootstrap-datetimepicker/src/js/datetimepicker.js"></script>
<!-- endbower -->
<!-- endbuild -->
...
app.js
angular
.module('c2gyoApp', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch',
'angularMoment',
'ui.bootstrap',
'ui.bootstrap.datetimepicker'
])
.config(function($routeProvider) {
$routeProvider
...
.when('/dtp', {
...
templateUrl: 'views/dtpform.html',
...
}).
otherwise({
redirectTo: '/c2g'
});
});
...
Any Ideas what is causing this behaviour?
Upvotes: 4
Views: 2622
Reputation: 2430
The href="#"
appear to be the problem. The href tag will be telling the angular router to navigate to the route that matches /#
. If you remove that, the dropdown should open ok.
Upvotes: 6