How to use bootstrap datepicker - jquery plugin in AngularJS -


i want use plugin in angularjs in export table filters. possible use ng-model , other uses

the plugin : https://uxsolutions.github.io/bootstrap-datepicker/?markup=input&format=&weekstart=&startdate=&enddate=&startview=0&minviewmode=0&maxviewmode=4&todaybtn=false&clearbtn=false&language=en&orientation=auto&multidate=&multidateseparator=&keyboardnavigation=on&forceparse=on#sandbox

especially need "range" -from/to . option

to use uxsolutions bootstrap-datepicker in angularjs, create custom directive this:

app.directive("datepicker", function() {     return {       restrict: "a",       require: "ngmodel",       link: function(scope, elem, attrs, ngmodelctrl) {           elem.on("changedate", updatemodel);           elem.datepicker({});            function updatemodel(event) {               ngmodelctrl.$setviewvalue(event.date);           }       }     } }) 

usage:

<div datepicker id="mydatepicker" ng-model="mydate"></div> <div> {{mydate | date }} </div>  

the demo

angular.module("app",[])  .directive("datepicker", function() {      return {        restrict: "a",            require: "ngmodel",            link: function(scope, elem, attrs, ngmodelctrl) {              elem.on("changedate", updatemodel);              function updatemodel(event) {                ngmodelctrl.$setviewvalue(event.date);              }              elem.datepicker({});            }      };  })
<script src="//unpkg.com/jquery"></script>      <script src="//unpkg.com/bootstrap-datepicker"></script>      <script src="//unpkg.com/angular/angular.js"></script>      <link href="//unpkg.com/bootstrap-datepicker/dist/css/bootstrap-datepicker.standalone.css" rel="stylesheet">    <body ng-app="app">      <div>selected date: {{mydate | date}}</div>      <div datepicker ng-model="mydate"></div>    </body>


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -