简体   繁体   中英

datepicker not working inside ng-view with bootstrap-datepicker

I am trying to implement the datepicker plugin developped by eternicode and I am experiencing some hurdles with ng-view.

I found similar cases but none helped me solving this (eg controller in the routeProvider) :

When my datepicker is inside index.html it works fine, but when I use a template view, the calendar doesn't popup.

Here's a plunkr to illustrate this case : plunkr

<div ng-view></div>

  <div class="container">
      <div class="col-lg-2">
          <div class="input-group date">
              <input type="text" class="form-control"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
          </div>
      </div>
  </div>

At the time when the js is running at the bottom of your index.html file, the view hasn't been loaded yet.

I moved the plugin code initialization code to the controller to demonstrate that it will work if the code is executed after the view has been loaded. You may want to rethink how you are setting up your app.

Plunker: http://plnkr.co/edit/PDX500tp5QgcjIMIbig1?p=preview

UPDATED: using a directive instead: http://plnkr.co/edit/LVKHkmNrTS2Ki7uP8Hgj?p=preview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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