Javascript 如何在引导daterangepicker日期更改时更新绑定?

Javascript 如何在引导daterangepicker日期更改时更新绑定?,javascript,angularjs,date-range,Javascript,Angularjs,Date Range,我正在使用AngularJS应用程序和变量来存储开始和结束日期,只要它们发生变化 在日期范围更改时,如何调用控制器方法来更新页面上的数据 类似于调用作用域的此方法: $scope.updateDataOnDateRangeChange = function(){ // here calling few services to fetch new data for the page // for the selected date range } 如何为该插件使用ng click

我正在使用AngularJS应用程序和变量来存储开始和结束日期,只要它们发生变化

在日期范围更改时,如何调用控制器方法来更新页面上的数据

类似于调用作用域的此方法:

$scope.updateDataOnDateRangeChange = function(){
    // here calling few services to fetch new data for the page
    // for the selected date range
}
如何为该插件使用ng click、ng change或custom指令?

AngularJS中有一个应用程序,它应该满足您的描述


将此指令添加到日期范围输入元素

使用jQuery插件的基本过程通常是为它创建一个指令。在
链接
回调中初始化插件。在这里,您可以作为jQuery或jqLite对象访问元素、角度范围和插件回调。在第三方代码中更改作用域时,请参阅有关uing
$.apply()
的重要注释

示例html:

<input my-picker type="text"/>

您可以通过将其他属性添加到标记中,然后使用这些属性设置各种插件选项来增强此指令。

不太可能触发,因为当值使用scriptalot更改时,浏览器无法识别更改事件。我要试一试。是的,在这个函数(start,end){}这是一个回调函数,我想我可以调用我的服务来更新所选日期范围的数据。还将服务作为依赖项添加到指令<代码>应用程序指令('myPicker',函数($timeout,TheServiceIWant){…
app.directive('myPicker', function ($timeout) {
    return {
        link: function (scope, elem, attrs) {
            $timeout(function () {
                /* elem is a jQuery or jQ-lite object representing the element*/
                elem.daterangepicker({
                    format: 'YYYY-MM-DD',
                    startDate: '2013-01-01',
                    endDate: '2013-12-31'
                },
               /* not overly familiar with this plugin but this callback 
                 should allow you to set angular scopes */
                function (start, end) {
                    /* important to do any scope changes within `$.apply()` so angular
                      becomes aware of changes from third party code*/
                    scope.$apply(function(){
                        /* do what you need here with angular scope
                         have access to plugin data as well as angular scope*/

                    })
                });
            }, 1)
        }
    }

})