AngularJS - jQuery UI - binding issue

后端 未结 7 1550
盖世英雄少女心
盖世英雄少女心 2021-01-02 10:14

I am currently porting a large application over to a HTML5 based web app - I have started building the app in AngularJS and enjoying the power of the AngularJS framework - I

相关标签:
7条回答
  • 2021-01-02 11:18

    I had just trimmed the code, have a look at this: http://jsfiddle.net/YU5mV/

    HTML

    <input id="date1" value="1/1/1980"  ng-model="fromDate" my-datepicker />
    <input id="date2" value="1/1/1980" ng-model="toDate" my-datepicker />
    

    JavaScript

    angular.module('myApp.directives', [])
      .directive('myDatepicker', function() {
        return function(scope, element, attrs) {     
    
           element.datepicker({
             changeYear : true,
             changeMonth : true,
             appendText : '(yyyy-mm-dd)',
             dateFormat : 'yy-mm-dd', 
                onSelect: function(dateText) {                    
                    var mdlAttr = $(this).attr('ng-model');
                    scope[mdlAttr] = dateText;                    
                    scope.$apply();                                                   
                }                
            });
    
        }
      });
    
    0 讨论(0)
提交回复
热议问题